Notes on setting up Pi-hole in a container.
Following Docker Pi-hole. I’m not running DHCP from Pi-hole, rather that is handled by USG Unifi.
-
Create
/opt/pihole-docker/docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
version: "3" # More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/ services: pihole: container_name: pihole image: pihole/pihole:latest # For DHCP it is recommended to remove these ports and instead add: network_mode: "host" ports: - "53:53/tcp" - "53:53/udp" - "80:80/tcp" # - "67:67/udp" # Only required if you are using Pi-hole as your DHCP server environment: TZ: 'Europe/Dublin' WEBPASSWORD: '' # set a secure password here or it will be random # Volumes store your data between container upgrades volumes: - './etc-pihole/:/etc/pihole/' - './etc-dnsmasq.d/:/etc/dnsmasq.d/' # Recommended but not required (DHCP needs NET_ADMIN) # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities cap_add: - NET_ADMIN restart: unless-stopped
- My
etc/netplan/01-netcfg.yaml
1 2 3 4 5 6 7
network: version: 2 ethernets: enp1s0: dhcp4: true enp2s0: dhcp4: true
- Disable
systemed-resolve
1 2
sudo systemctl stop systemd-resolved sudo systemctl disable systemd-resolved
- Create
/etc/resolv.conf
Originally it is a symlin:1 2
➜ pihole-docker ll /etc/resolv.conf lrwxrwxrwx 1 root root 39 Sep 24 09:50 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
Remove it and create a file:
1 2
nameserver 127.0.0.1 search carltons.us
- If you’re running Tailscale and have MagicDNS enabled, turn it off so that it does not overwrite
/etc/resolv.conf
(see https://tailscale.com/kb/1235/resolv-conf)1
sudo tailscale set --accept-dns=false
- Fire it up
1
docker-compose up -d
-
Migrate over settings from previous installation Use ‘Settings -> Teleporter’ Backup
Copy to new installation and restore appropriately.
-
Clean up
-
If
pi.hole
resolves to 0.0.0.0, edit the address in./etc-pihole/pihole-FTL.conf
-
Note that
/admin
path is now required (unless you access viahttp://pi.hole
).
-
- My