Adding a PiHole Docker Container Container

Adding a PiHole Docker Container Container

If you’re like me and you hate being spammed with advertisements in your browser than something like PiHole is for you.  If you’ve ever heard the commercials for DuckDuckGo you are probably familiar with what happens:  you search for something in your browser and next thing you know you are spammed with advertisements related to your search.  If you install something like PiHole on your network these advertisements will disappear because the requests to the ads go into a DNS black hole.

As you may know I have a heavy-duty server in my closet known as “HAL”.  HAL is running Open Media Vault, and Docker is running on top of that.  I am not going to address how to set all of that up here as that has been covered in many other places.   This guide partly for my reference in the future and partly for anyone searching on how to add run PiHole in a container with a static IP address (this is something that most guides leave out).

The key to all of this is to identify the specifics for your network:

Note that my network uses the pattern 192.168.1.x.

version: "2"

container_name: pihole
image: pihole/pihole:latest
hostname: pihole
# domainname: # <-- Update or leave comment if you do not have
mac_address: d0:ca:ab:cd:ef:05 # <-- Update ( must be a random MAC, because you create a virtual NIC for it)
macvlan_NET: # <-- MACVlan Name no need to change, but do not exist previosly.
ipv4_address: # <-- Update to whatever IP that you want to use as DNS sever ( pihole IP)
- 443/tcp
- 53/tcp
- 53/udp
- 67/udp
- 80/tcp
ServerIP: # <-- Update (match docker host ipv4_address. In my case, OMV server)
# VIRTUAL_HOST: # <-- Update (match hostname + domainname)
WEBPASSWORD: "password" # <-- Add password (if required)
DNS2: # <-- Change by your prefered DNS service like
TZ: American/New_York # <-- You need to add in webGUI not here
# IPv6: False # <-- You need to add in webGUI not here
- /srv/dev-disk-by-label-HOMEMEDIA/AppData/PiHole:/etc/pihole # <-- Update to match your real path ; your_nas_path:/etc/pihole
- /srv/dev-disk-by-label-HOMEMEDIA/AppData/PiHole/dnsmasq.d:/etc/dnsmasq.d # same here
restart: unless-stopped

driver: macvlan
parent: br0 # <- Update to match your NIC see your OMV WebGUI
- subnet: # <-- Update
gateway: # <-- Update
ip_range: # <-- Update

Note that you SHOULD to run this through a yml validator in order to get the spacing right.

In the example above my personal IP address is in the 192.168.1.x range.  I set it so that the PiHole instance uses  This is a virtual IP address that I can then point to from my router in order to get DNS.  In order to get a virtual IP I had to create a new network called “macvlan_net”.  I could have done this manually in the UI but I chose to do it via code.

This is the network that is created in Portainer.

This is the PiHole container in action.


And here is PiHole doing its just.  I can access it through the browser using the IP address that I specific in the docker compose file.


Add a comment

*Please complete all fields correctly

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Blogs

No Image