A Docker container configuration for Tailscale with Pi-hole using Docker Compose.
This sets up two containers and allows the Tailscale container to be used as an exit node with ad blocking provided by the Pi-hole container.
Note
This configuration requires manually supplying the Pi-hole container's IP address to the Tailscale Docker Compose in order to correctly build the Tailscale container.
Instructions are included in the Getting Started section.
I would like to have this set up without manually having to retrieve and set the IP address but this is what I've got working at the moment.
Set variables as defined by Pi-hole's environment variables.
# pi-hole/.env
TZ=America/New_York
WEBTHEME=default-dark
WEBPASSWORD=my-pihole-admin-passwordFrom the pi-hole/ directory, run:
docker compose up -dThe Pi-hole admin ui will be available at http://localhost:8081/admin
From the host machine, run:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' piholeNote
pihole is the container name specified in pi-hole/docker-compose.yml but the container id can also be used as the last argument:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name_or_id>See step 2 of Create a container for Tailscale.
The Tailscale container configuration requires the Pi-hole container's IP address and the Tailscale auth key:
# tailscale/.env
PIHOLE_IP=X.X.X.X
TS_AUTHKEY=my-ts-auth-keyFrom the tailscale/ directory, run:
docker compose up -dNote
The Tailscale container can be configured via the tailscale/docker-compose.yml file.
See Using Tailscale with Docker for valid settings.
Re-run the build command after editing to update the container.