Blog

Run Pi-Hole in a Docker Container

I’m probably one of the last to setup a pi-hole and still not convinced it’s such a good idea. Will evaluate for a few weeks and then decide on what to do.

The pi-hole is setup as the primary DNS service for all DHCP connected devices. It will forward to my internal DNS (Windows AD) infrastructure which in turn forwards to the router (UBNT EdgeRouter). The Firewall forwards to OpenDNS. For the rylander.io domain, my internal DNS has a split personality and serveral sub domains are delegated to Cloudflare DNS which also duplicates some hostnames due to LetsEncrypt validation.

8cb2fb75-aec2-46c4-ac50-a01666a58eec.png

Dock distribution

I’m using the execellent distribution of https://github.com/diginc/docker-pi-hole which contains complete documentation. I’m using a minimal Photon VM and using the Alpine x86 release.

I did craft the docker-compose.yml myself, but only because I didn’t read carefully to see there is already one existing.

dock-distribution.png

docker-compose

It’s recommended to keep the data and confguration on the host in order to easily upgrade the container when new realases come out. It’s as simple as destroying the running container (docker-compose down) and then do a docker pull diginc/pi-hole:alpine followed by a docker-compose up -d.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
version: '2'
services:
pihole:
container_name: pihole
restart: unless-stopped
image: diginc/pi-hole:alpine
environment:
- ServerIP=10.0.1.9
- TZ=Europe/Stockholm
- WEBPASSWORD=*redacted*
- DNS1=10.0.1.6
- DNS2=10.0.1.22
- VIRTUAL_HOST=pihole.rylander.io
volumes:
- /root/pihole/:/etc/pihole/
- /root/pihole/dnsmasq.d/:/etc/dnsmasq.d/
ports:
- "80:80"
- "53:53/tcp"
- "53:53/udp"

I’ve registered pihole.rylander.io in my internal DNS (Windows AD). As I run this on a minimal host, it’s easy to expose non-conflicting ports.

The docker-compose file is placed in the /root/pihole folder.

1
docker-compose up

just to verify it starts without errors, then restart as daemon.

f1dc70b1-426a-4661-9443-e126e62d79b2.png

Update list of ad-serving domains

It’s a good idea to update the list so it’s current.

update-list-of-ad-serving-domains.png

Tailing the log

In order to verify, you can also tail the log for DNS requests.

tailing-the-log.png