This example provides a base setup for using Pi-hole with dnscrypt-proxy forwarding DNS queries to Cloudflare over HTTPS.
ℹ️ INFO This example used
cloudflareduntil its DNS proxy mode was removed in version 2026.2.0. More details on how to customize the installation and the compose file can be found in Docker Pi-hole documentation.
Project structure:
.
├── .env
├── compose.yaml
├── dnscrypt-proxy
│ └── dnscrypt-proxy.toml
└── README.md
services:
pihole:
image: pihole/pihole:latest
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "8080:80/tcp"
- "8443:443/tcp"
...
dnscrypt-proxy:
image: klutchell/dnscrypt-proxy:latest
ports:
- "5054:5054/tcp"
- "5054:5054/udp"
...
Before deploying this setup, you need to configure the following values in the .env file.
If you would like to disable conditional forwarding, delete the FTLCONF_dns_revServers environment variable.
The upstream DoH resolver is configured in dnscrypt-proxy/dnscrypt-proxy.toml.
In the docker compose file, dns is added as a comment. To enable dns remove '#' in front of the following lines:
dns:
- 127.0.0.1 # "Sets your container's resolve settings to localhost so it can resolve DHCP hostnames [...]" - github.com/pi-hole/docker-pi-hole
- 1.1.1.1 # Backup server
When deploying this setup, the admin web interface will be available on port 8080 (e.g. http://localhost:8080/admin).
$ docker compose up -d
Starting dnscrypt-proxy ... done
Starting pihole ... done
Check containers are running and the port mapping:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
afcf5ca4214c pihole/pihole:latest "/s6-init" 3 seconds ago Up 3 seconds (health: starting) 0.0.0.0:53->53/udp, 0.0.0.0:53->53/tcp, 0.0.0.0:67->67/udp, 0.0.0.0:8080->80/tcp, 0.0.0.0:8443->443/tcp pihole
dfd49ab7a372 klutchell/dnscrypt-proxy:latest "dnscrypt-proxy -con…" 4 seconds ago Up 3 seconds 0.0.0.0:5054->5054/tcp, 0.0.0.0:5054->5054/udp dnscrypt-proxy
Navigate to http://localhost:8080 in your web browser to access the installed Pi-hole web interface.
Stop the containers with
$ docker compose down
# To delete all data run:
$ docker compose down -v
Sometimes, it can happen that there occurs a problem starting pihole-FTL. I personally had this issue when adding this line to the shared volumes:
- "/pihole/pihole.log:/var/log/pihole.log"
To fix this issue, I found this issue,
which suggested adding an empty file (touch /pihole/pihole.log) to prevent it from creating a directory.
The directory would not allow starting pihole-FTL and result in something like this:
# Starting pihole-FTL (no-daemon) as root
# Stopping pihole-FTL
...
If you created an empty file, you may also check the ownership to prevent permission problems.
systemd-resolved - see Installing on Ubuntu for help.Since Pi-hole v6, settings are passed with FTLCONF_* environment variables (e.g. FTLCONF_webserver_api_password, FTLCONF_dns_upstreams),
the v5 variables (WEBPASSWORD, PIHOLE_DNS_, REV_SERVER*...) are no longer supported.
Current information about environment variables can be found here: https://github.com/pi-hole/docker-pi-hole