How to Set up PiHole with Docker on your Home Network (Ft: Traefik Reverse Proxy)
[WIP]
What is PiHole?
- Connected devices
- DNS queries made
- Blocked domains and IPs
What is Docker?
Why use Docker?
- Pull the app image from Docker Hub
- Configure it via a simple docker-compose.yml
- Run it in seconds
How to Use Docker
- Install Docker → Get Docker
- Install Docker Compose → Get Docker Compose
Installation
With Traefik
Bash
mkdir traefik
cd traefik
vim docker-compose.yml
Yaml
version: "3.3"
services:
traefik:
image: "traefik:v2.4"
container_name: "traefik"
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "443:443"
- "52:52" # only needed if you want to use DNS over HTTPS
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- lan
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`traefik.local`)"
- "traefik.http.routers.api.service=api@internal"
- "traefik.http.routers.api.entrypoints=web"
networks:
lan:
external: true
PiHole
Bash
mkdir pihole
cd pihole
vim docker-compose.yml
Yaml
version: "3.3"
services:
pihole:
image: "pihole/pihole:latest"
container_name: "pihole"
environment:
- TZ="Australia/Melbourne"
- WEBPASSWORD="yourpassword"
- DNS1=8.8.8.8
Copy/Paste TL;DR
Bash
mkdir traefik-pihole
cd traefik-pihole
vim docker-compose.yml
Yaml
version: '3'
services:
traefik:
container_name: traefik
domainname: homedomain.lan
image: traefik
restart: unless-stopped
command: "--web --docker --docker.domain=homedomain.lan --docker.exposedbydefault=false --logLevel=DEBUG"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
networks:
- default
- discovery
dns:
- 192.168.1.50
- 192.168.1.1
pihole:
container_name: pihole
domainname: homedomain.lan
image: diginc/pi-hole:debian
ports:
- '0.0.0.0:53:53/tcp'
- '0.0.0.0:53:53/udp'
- '0.0.0.0:67:67/udp'
- '0.0.0.0:8053:80/tcp'
volumes:
- ./etc-pihole/:/etc/pihole/
- ./etc-dnsmasqd/:/etc/dnsmasq.d/
environment:
ServerIP: 192.168.1.50
PROXY_LOCATION: pihole
VIRTUAL_HOST: pihole.homedomain.lan
VIRTUAL_PORT: 80
TZ: 'America/Chicago'
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.frontend.rule=HostRegexp:pihole.homedomain.lan,{catchall:.*}"
- "traefik.frontend.priority=1"
- "traefik.backend=pihole"
- "traefik.port=80"
networks:
discovery:
external: true
✅ Done! You now have PiHole running behind Traefik in Docker — no Raspberry Pi required. Enjoy network-wide ad blocking and analytics right from your browser.