Install Pi-Hole on OMV with DOCKER COMPANY AND DEDICATE IP
P-Hole is a popular DNS Filtering and Ad-Blocking software that allows you to block advertising, Sendered trackers and domains at the network level. In this guide we will see how to install it on a home server with OpenMediaVault (OMV), using Docker Compose, with two fundamental precautions:
- Use the physical volumes of the disc e non mergerfs, To avoid corrupting the database
gravity.db. - Assign a dedicated static IP to P-Hole instead of a simple door, so that you can use it as a primary DNS on the whole network.
Prerequisites
- A server with OMV installed and working.
- Docker and Docker composed activated by the OMV-EXTRAS plugin.
- A LAN network configured with DHCP (For example from your router).
- A free IP to dedicate to Pi-Hole (In the example we will use
192.168.5.53).
Prepare the folders
First we create the directories where Pi-Hole will save the data. It is important that these directories are on a real physical disc and not on Mergerfs:
mkdir -p /srv/dev-disk-by-uuid-XXXXXX/docker_appdata/pihole/etc-pihole
mkdir -p /srv/dev-disk-by-uuid-XXXXXX/docker_appdata/pihole/etc-dnsmasq.d
Replace XXXXXX With the Uuid of the Royal Disco you see in OMV (the command lsblk -f helps you identify it).
File docker-compose.yml
We create the file in the project folder:
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
environment:
TZ: 'Europe/Rome'
WEBPASSWORD: 'scegliUnaPasswordSicura'
volumes:
- /srv/dev-disk-by-uuid-XXXXXX/docker_appdata/pihole/etc-pihole:/etc/pihole
- /srv/dev-disk-by-uuid-XXXXXX/docker_appdata/pihole/etc-dnsmasq.d:/etc/dnsmasq.d
dns:
- 127.0.0.1
- 1.1.1.1
network_mode: "macvlan"
restart: unless-stopped
cap_add:
- NET_ADMIN
Configure the network macvlan
To assign a pi-hole a Dedicated IP, A Macvlan network must be created. First we stop the containers, Then from the terminal:
docker network create -d macvlan \
--subnet=192.168.5.0/24 \
--gateway=192.168.5.1 \
-o parent=eth0 \
pihole_network
Change eth0 With the real interface of your server (the command ip a helps you identify it).
Change 192.168.5.0/24 and 192.168.5.1 with the parameters of your LAN.
Then we modify the service in docker-compose.yml To hook up to this network and have a static IP:
networks:
default:
external:
name: pihole_network
services:
pihole:
networks:
default:
ipv4_address: 192.168.5.53
Start pi-hole
Contain the container:
docker compose up -d
After a few seconds, The web interface will be available on:
http://192.168.5.53/admin
Log in with the password you have chosen in WEBPASSWORD.
Configure the network
Now you can set the IP 192.168.5.53 come Primary DNS in your router, Thus all the devices of the network will use P-Hole. In alternative, You can manually configure the DNS on individual clients.
Conclusion
With this configuration you have a pi-hole:
- Stable, because the data are saved on physical disk.
- Accessible with a dedicated IP on the net.
- Ready to filter advertising and tracker at the LAN level.



0 Comments