How to Install Pi-Hole on OpenMediaVault 5 inside Docker with Portainer using Raspberry Pi 4

In this segment, we are going to show you how to configure “Pi-Hole on Docker with Portainer using OpenMediaVault 5 Raspberry Pi 4 

What is Pi-Hole?


Pi-hole is a free and open-source network-wide adblocker. This allows traffic to pass through its DNS server and block the predefined queries from the internet. It is based on  Linux network-level advertisement and Internet tracker blocking the application.  


OpenMediaVault Versions :

OpenMediaVault 5 Installation Guide :

Software Required :

Equipment Required Optional
Raspberry Pi Raspberry Pi 4 Case
SD_Card SD Card
Raspberry Pi Keyboard
Ethernet Ethernet Cable Mouse
Charger Power Adapter    
HDD External HDD    
Shop now

We may earn a commission for purchases using our links. Learn more.


Checkout official website: pi-hole


version: "3"

# More info at and
    container_name: pihole
    image: pihole/pihole:latest
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
      - "443:443/tcp"
      TZ: 'Asia/Kolkata'
      # WEBPASSWORD: 'set a secure password here or it will be random'
    # Volumes store your data between container upgrades
       - './etc-pihole/:/etc/pihole/'
       - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
    # Recommended but not required (DHCP needs NET_ADMIN)
      - NET_ADMIN
    restart: unless-stopped

Note: Please change the OMV default port from 80 to something else and then start with

sudo apt update
sudo apt dist-upgrade

Configuring Openmediavault Network Interface

  • First, we need to configure our DNS servers from Openmediavault Network Interface. Here we need to navigate to Network –> Interfaces and edit the Network.
  • However, we need to configure the DNS Server from Advanced settings to or as shown in Pi-Hole Docker-compose.


Create Macvlan Network for Pi-Hole

  • Once the DNS is successfully configured then we need to open Putty and login to our OpenMediaVault with root user.
  • After that, enter the below-given command to create Macvlan network for Pi-Hole. Remember to change the subnet to your OpenMediaVault IP Address.
docker network create -d macvlan \
    --subnet= \
    --gateway= \
    -o parent=eth0 pub_net

Configure Pi-Hole container

  • Now, to pull the image we need to search for Pi-Hole container from the image box.
  • And look for the latest pihole/pihole:latest image and click on pull the image to download the latest pihole image.

OpenMediaVaultClick to ZOOM

  • Once the image is successfully downloaded then we need to navigate to Containers and then click on Add container.
  • After that, fill the details as mentioned below in the picture, Choose a name for your container and image name as pihole/pihole:latest.

Note: If you came across Port 53 bind error use the below-given command.

sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved


PiholeClick to ZOOM

  • In the volume section, we need to configure the path for /etc/pihole/, and /etc/dnsmasq.d/ folders then bind these folders to our desired path.

Pi-HoleClick to ZOOM

  • In the network section, use the below-given instructions to configure the container.
Network: Select the Macvlan network that we have created 
Hostname: Create a Host Name for your Pi-Hole 
IPv4 Address: Type an IP Address for your Pi-Hole
Primary DNS:
Secondary DNS:

Pi-HoleClick to ZOOM

  • After that, we need to configure Environment Variables as mentioned below in the picture.
ServerIP : "Type the Pi-Hole IP Address, which we created" 
TZ: "Asia/kolkata", Type your Time Zone 
WEBPASSWORD : "Password of your choice"

Pi-HoleClick to ZOOM

  • In this section we need to select unless stopped.

wordpressClick to Zoom

  • In this section, we need to enable NET_ADMIN from the list.


Click to Zoom

  • Finally, once everything is done we can go ahead and click on Deploy the container.


Access Pi-Hole Server Web Interface

  • To access the Pi-Hole web interface we need to type the Pi-Hole IP Address/admin.
  • However, our Pi-Hole is not yet ready for blocking Ads on our Network. We need to update Pi-Hole IP Address to our Router DNS.


http://Pi-Hole IP Address/admin/

Updating Pi-Hole IP Address to Router DNS

  • At this moment we need to log in to our Router, then Navigate to DNS Settings.
  • After that, we need to enter the Pi-Hole IP Address to our Router Primary DNS Address.
  • Finally, all the traffic will route through the Raspberry Pi and Block ads with Pi-Hole.
Primary DNS Address   : "Pi-Hole IP Address"
Secondary DNS Address : "Cloudflare DNS Address i.e"

router DNS

Reset Pi-Hole Password

  • If you forgot the Pi-Hole password you can reset it anytime by using this command inside Terminal.
docker exec -it pihole pihole -a -p

In conclusion

  • Above all steps will convert your Raspberry Pi 4 as Pi-Hole Network Wide Ad-Block Server.
  • If you face any issue regarding this article please share your thoughts.
  • Enjoy using Pi-Hole on Docker using Openmediavault. Smile (.”_”.)

Please check out my other articles:

Did you find us helpful?

Subscribe our YouTube Channel YouTube
Support us on Patreon Patreon
Like us on Facebook facebook
Share This Article with others

Harish Kumar

As a founder of the PcMac YouTube channel and website, Our goal is to provide Free Technical help to people and spread knowledge to everyone.
0 0 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
4 years ago

Hello, thanks for the amazing work on this guide however may I ask as a novice in the container field was there a portion missing of this guide that was meant to be assumed? mostly pertaining to Docker? I know how to install docker..can’t figure out the docker part 🙁

Reply to  Harish Kumar
3 years ago

no matter what I try, how i try..different SD cards etc… I get this error when trying to make ANY changes in openmediavault

“Failed to execute command ‘export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LANG=C.UTF-8; omv-salt deploy run systemd-networkd 2>&1’ with exit code ‘1’: raspberrypi: ———- ID: configure_etc_network_interfaces Function: file.managed Name: /etc/network/interfaces Result: True Comment: File /etc/network/interfaces is in the correct state Started: 19:08:57.134029 Duration: 80.373 ms Changes: ———- ID: remove_systemd_networkd_config_files Function: Result: True Comment: file.find: [] Started: 19:08:57.216200 Duration: 3.517 ms Changes: ———- file.find: ———- ID: remove_empty_systemd_networkd_config_files Function: Result: True Comment: file.find: [] Started: 19:08:57.220028 Duration: 2.975 ms Changes: ———- file.find: ———- ID: remove_netplan_config_files Function: Result: True Comment: file.find: [‘/etc/netplan/10-openmediavault-default.yaml’, ‘/etc/netplan/20-openmediavault-eth0.yaml’, ‘/etc/netplan/20-openmediavault-eth1.yaml’, ‘/etc/netplan/20-openmediavault-veth9dc499e.yaml’] Started: 19:08:57.223305 Duration: 3.975 ms Changes: ———- file.find: – /etc/netplan/10-openmediavault-default.yaml – /etc/netplan/20-openmediavault-eth0.yaml – /etc/netplan/20-openmediavault-eth1.yaml – /etc/netplan/20-openmediavault-veth9dc499e.yaml ———- ID: configure_netplan_default Function: file.managed Name: /etc/netplan/10-openmediavault-default.yaml Result: True Comment: File /etc/netplan/10-openmediavault-default.yaml updated Started: 19:08:57.227589 Duration: 21.718 ms Changes: ———- diff: New file mode: 0644 ———- ID: configure_netplan_ethernet_eth0 Function: file.managed Name: /etc/netplan/20-openmediavault-eth0.yaml Result: True Comment: File /etc/netplan/20-openmediavault-eth0.yaml updated Started: 19:08:57.249618 Duration: 71.522 ms Changes: ———- diff: New file mode: 0644 ———- ID: configure_netplan_ethernet_eth1 Function: file.managed Name: /etc/netplan/20-openmediavault-eth1.yaml Result: True Comment: File /etc/netplan/20-openmediavault-eth1.yaml updated Started: 19:08:57.321573 Duration: 64.298 ms Changes: ———- diff: New file mode: 0644 ———- ID: configure_netplan_ethernet_veth9dc499e Function: file.managed Name: /etc/netplan/20-openmediavault-veth9dc499e.yaml Result: True Comment: File /etc/netplan/20-openmediavault-veth9dc499e.yaml updated Started: 19:08:57.386233 Duration: 58.607 ms Changes: ———- diff: New file mode: 0644 ———- ID: apply_netplan_config Function: Name: netplan apply Result: False Comment: Command “netplan apply” run Started: 19:08:57.446814 Duration: 273.291 ms Changes: ———- pid: 6100 retcode: 78 stderr: /etc/netplan/20-openmediavault-eth1.yaml:5:20: Error in network definition: Invalid MAC address ”, must be XX:XX:XX:XX:XX:XX macaddress: ^ stdout: Summary for raspberrypi ———— Succeeded: 8 (changed=8) Failed: 1 ———— Total states run: 9 Total run time: 580.276 ms”

3 years ago

Three quick questions: Any particular reason why you suggest moving OMV away from port 80 and give it to the pihole rather than simply mapping the pihole port 80 to an unused port?

Second question: Why use a macvlan in a setup where pihole is running under the same IP as OMV? My intuition would have been that host networking would be the best choice under these conditions. Isn’t the main advantage of the macvlan setup that the pihole will get its own IP address so that you don’t have to worry about port conflicts with the host? (This is how I am currently running my pihole, but the downside is that host and pihole cannot communicate with each other when the pihole is on the macvlan. So I’m thinking about changing it to the host network… Am I missing something?)

Third question: Why would I set my DNS server on OMV to given that the whole point of running a pihole is to use it as your DNS?

3 years ago

Thanks for the tutorial. But the macvlan is probably messing something up. I set up :
docker network create -d macvlan \
  –subnet= \
  –gateway= \
  -o parent=eth0 pub_net

My omv was on 100 and my router is on 1.
and then chose for the pi-hole.

The pihole works fine but now I cannot access anymore where is OMV and all my other containers…so completely stuck here, any suggestion to solve that?


3 years ago

Great tutorial! Works great deploying thru the portainer gui. I would like to deploy it thru the stack/web editor of portainer. With the pihole_net network already created, what is the syntax to add to the the network settings in the docker-compose, I’m assuming under Network:

Florian R.
Florian R.
3 years ago

Hello, thanks for your tutorial. I have an issue when starting the container. I have posted a Question on StackOverflow, maybe you can have a look at it?

3 years ago

[…] I am currently following this tutorial with a clean OpenMediaVault installation on my Raspberry Pi 4: […]