Pi-hole
Use these steps to run Pi-hole with Docker Compose.
For more details, review the official Pi-hole Docker repository and documentation:
https://github.com/pi-hole/docker-pi-hole/
https://docs.pi-hole.net/
Create the Compose File
Create a docker-compose.yml file with the Pi-hole service:
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
- "80:80/tcp"
- "443:443/tcp"
# Uncomment if using Pi-hole as your DHCP server.
# - "67:67/udp"
# Uncomment if using Pi-hole as your NTP server.
# - "123:123/udp"
environment:
TZ: ${TZ}
FTLCONF_webserver_api_password: ${PIHOLE_WEB_PASSWORD}
FTLCONF_dns_listeningMode: ${PIHOLE_DNS_LISTENING_MODE}
volumes:
- ./etc-pihole:/etc/pihole
# Uncomment if you have custom dnsmasq config files to persist.
# - ./etc-dnsmasq.d:/etc/dnsmasq.d
cap_add:
- NET_ADMIN
- SYS_TIME
- SYS_NICE
restart: unless-stopped
Create the Environment File
Create a .env file in the same directory as docker-compose.yml:
TZ=Europe/London
PIHOLE_WEB_PASSWORD=correct-horse-battery-staple
PIHOLE_DNS_LISTENING_MODE=ALL
Start Pi-hole
Run Docker Compose from the directory containing both files:
docker compose up -d
Pi-hole will be available at http://localhost/admin.
If another service already uses ports 80 or 443, change the host-side ports before starting Pi-hole.
Reverse Proxy / HTTPS
If you need HTTPS access to the Pi-hole web UI, put it behind a reverse proxy like Nginx Proxy Manager. DNS traffic on port 53 still needs to be handled separately.