Pi-hole is a free DNS server that blocks ads, trackers and malware sites for every device in your home, from one small machine. This guide installs Pi-hole v6 with Docker Compose, fixes the "port 53 already in use" error you get on Ubuntu, and then walks through the web interface one screen at a time: upstream DNS and DNSSEC, blocklists, separate rules for a child's phone, allowing a site that broke, local names, backups, a hardened compose file and safe updates.
Tested on 25 November 2026: Pi-hole Docker tag 2026.11.0 (Core v6.6, web interface v6.6.1, FTL v6.9) in Docker 29.10.1 with Docker Compose v5.8.0, on an Ubuntu 26.04 home server at 192.168.1.50. Three devices on the same network used it: a laptop (192.168.1.21), a TV (192.168.1.23) and a test machine at the address of a child's phone (192.168.1.22). Every screenshot and output below comes from that lab.
Quick answer: Pi-hole with Docker Compose in five steps
In plain words: DNS is the internet's phone book. Before any app or site loads, your device asks a DNS server for the address of a name. Pi-hole becomes that phone book for your whole home: it looks up normal names for your devices and gives ad and tracker names a dead end (0.0.0.0), so they never load.
- Give your server an address that never changes (a DHCP reservation on the router). Ours is 192.168.1.50.
- Create
compose.yamlwith the imagepihole/pihole:2026.11.0, the password in a Docker secret,FTLCONF_dns_listeningMode: ALL, and ports 53, 80 and 443 published on that address (192.168.1.50:53:53/udp): on Ubuntu, systemd-resolved already uses port 53. - Run
docker compose up -d, openhttp://192.168.1.50/adminand log in. - Test from one device:
dig @192.168.1.50 pagead2.googlesyndication.com +shortmust print0.0.0.0. Then set your router's DHCP DNS server to the Pi-hole address. - Add two settings so the name
pi.holeworks from your devices:FTLCONF_dns_reply_host_force4: "true"andFTLCONF_dns_reply_host_IPv4set to the server's address. In Docker, Pi-hole otherwise answers with the container's own address.
Each step has a full, tested section below. The result in our lab:

Five words you will meet in this guide:
- Upstream: the public DNS service Pi-hole asks for the names it does not block.
- Blocklist: a list of ad, tracker and malware names, downloaded from the internet.
- Gravity: Pi-hole's database of every blocked name, built from your blocklists.
- Client and group: a client is one device, known by its address; a group is a set of rules you can give to some clients only.
- Port 53: the network port of DNS. On one address, only one program can use it.
What Pi-hole v6 changed, and which version to run
Pi-hole v6 is a big rework of the project. The web server and the API now run inside FTL, Pi-hole's DNS engine, so there is no separate web server or PHP any more, and every setting lives in one file: /etc/pihole/pihole.toml. In Docker you can set any of those settings with an environment variable: dns.listeningMode becomes FTLCONF_dns_listeningMode. A setting set this way is locked in the web interface (you will see a padlock), so compose.yaml stays the one place that decides it.
The Docker image has date tags (2026.11.0), and each tag ships a given Core, web interface and FTL version; the footer of every admin page shows all four. Run 2026.11.0 or newer: it came out on 11 November 2026 with FTL v6.9 and Core v6.6, which fix 11 security advisories, several of them rated High. The image runs on linux/amd64, arm64, arm/v7, arm/v6, 386 and riscv64, so a mini PC, an old laptop or a Raspberry Pi all work.
Before you start
- A Linux machine that stays on, with Docker and the Compose plugin (install Docker Compose on Ubuntu).
- A fixed LAN address for that machine. Every device will send its lookups there, so it must never change. A DHCP reservation in the router is the easiest way.
- Five minutes to check what already uses port 53.
docker --version
docker compose version
ip route get 1.1.1.1
sudo ss -lunp "sport = :53"
src is the server's own LAN address. 4: systemd-resolved already holds port 53 on 127.0.0.53 and 127.0.0.54.The src address is the one your devices will use. On Ubuntu, systemd-resolved listens on 127.0.0.53 and 127.0.0.54, port 53. That is the reason for the error in step 1, and you do not need to switch systemd-resolved off.
Step 1: Create the Compose file (and fix "port 53 already in use")
Make a folder for Pi-hole, a folder for its data, and a random admin password in a file only you can read:
mkdir -p ~/pihole && cd ~/pihole
mkdir -p etc-pihole && (umask 077 && openssl rand -base64 18 > pihole_password.txt) && ls -lThen compose.yaml. This is the usual Pi-hole quick-start file with two changes: a fixed image tag instead of latest, and the password read from a Docker secret instead of written in the file:
services:
pihole:
image: pihole/pihole:2026.11.0
container_name: pihole
hostname: pihole
restart: unless-stopped
ports:
- "53:53/tcp"
- "53:53/udp"
- "80:80/tcp"
- "443:443/tcp"
environment:
TZ: America/New_York
FTLCONF_dns_listeningMode: ALL
WEBPASSWORD_FILE: pihole_webpasswd
secrets:
- pihole_webpasswd
volumes:
- ./etc-pihole:/etc/pihole
secrets:
pihole_webpasswd:
file: ./pihole_password.txtFTLCONF_dns_listeningMode: ALL: in Docker's default bridge network, your devices' lookups do not come from a network Pi-hole sees as local, so the default mode would refuse them. This is safe as long as your router does not forward port 53 from the internet.WEBPASSWORD_FILEandsecrets: Pi-hole reads the password frompihole_password.txtat start, so it never appears incompose.yaml../etc-pihole: settings, lists and history live here, so they survive updates.
Start it. On Ubuntu, the first try fails:
docker compose pull --quiet
docker compose up -d
53:53 ports fail on Ubuntu: systemd-resolved got there first.53:53 means "port 53 on every address of this machine", and systemd-resolved already has 127.0.0.53. Publish the ports on the server's LAN address only. The sed line below edits the four ports in place; change 192.168.1.50 to your own address:
sed -i 's/- "53:53/- "192.168.1.50:53:53/; s/- "80:80/- "192.168.1.50:80:80/; s/- "443:443/- "192.168.1.50:443:443/' compose.yaml && grep -A4 'ports:' compose.yaml
docker compose up -d
docker compose ps --format "table {{.Name}}\t{{.Image}}\t{{.Status}}"
sudo ss -lntup "sport = :53"
Check the logs once. They show the password source, the versions and that DNS is listening:
docker compose logs pihole | grep -i -E "password|version is|FTL started|listening on|WARNING" | head -14
Step 2: Log in to the web interface
Open http://192.168.1.50/admin from a computer on the same network. Print the password once with cat pihole_password.txt, paste it, and log in. Store it in your password manager.

pihole_password.txt. 2: Log in.Step 3: Test one device, then point your router at Pi-hole
Before you change anything for the whole house, ask Pi-hole directly from one computer. dig comes with the dnsutils package on Debian and Ubuntu:
dig @192.168.1.50 example.com +noall +answer +stats | grep -E "IN|Query time"
dig @192.168.1.50 pagead2.googlesyndication.com +short
dig @192.168.1.50 www.google-analytics.com +short
0.0.0.0.Now make every device use it. In your router's LAN or DHCP settings, set the DNS server to 192.168.1.50. If there is a second DNS field, leave it empty or put the same address: devices use the second server whenever they like, and the lookups that go there are not filtered. Reconnect a device to Wi-Fi so it gets the new setting, then check that its address shows in the Query Log.
Some routers hand out their own address and pass lookups on to Pi-hole. Blocking still works, but every lookup then shows the router as the client, and the per-device rules of step 7 cannot tell your devices apart. Android phones with Private DNS set to a provider's hostname skip Pi-hole completely (how DNS works on Android).
Step 4: Read the dashboard

The four boxes are clickable: Queries Blocked opens the list of blocked lookups, and Domains on Lists opens your lists. Lower on the page you will find the top allowed and blocked names and the top clients, the first place to look when a device behaves oddly.
Step 5: Choose upstream DNS servers and turn on DNSSEC
Pi-hole answers blocked names itself, and asks an upstream server for every other name. In Docker the default upstream is Google with ECS (EDNS Client Subnet), which passes part of your public IP address on to the DNS servers of the sites you visit, so they can pick a server near you. We switched to Cloudflare under Settings, DNS:

DNSSEC lets Pi-hole check that answers were not changed on the way. It is off by default. Switch the page to Expert mode (top right), tick Use DNSSEC and save:

The ad flag in the answer proves it works. dnssec-failed.org is a test domain with a broken signature:
docker exec pihole pihole-FTL --config dns.upstreams; docker exec pihole pihole-FTL --config dns.dnssec
dig @192.168.1.50 example.com +dnssec +noall +comments | grep -E "status|flags"
dig @192.168.1.50 dnssec-failed.org +noall +comments | grep status
ad flag. 3: the broken test domain already fails, because Cloudflare checks signatures itself. 4-6: after Use DNSSEC: 5: the ad flag (authenticated data).Expert mode also shows the settings your compose file controls. They have a padlock and cannot be changed here:

compose.yaml. 2: Permit all origins, the mode a Docker bridge network needs. Read the warning under it.Step 6: Add blocklists and update gravity
Pi-hole starts with one list, StevenBlack's hosts file (81,677 domains in our test). We added HaGeZi's Pro list, a well-kept list of ads, trackers and malware, in its Adblock format, the format its author gives for Pi-hole. Under Lists, paste the address and a comment, then Add blocklist:
https://cdn.jsdelivr.net/gh/hagezi/dns-blocklists@latest/adblock/pro.txt
A new list does nothing until gravity runs. Open Tools, Update Gravity, and press Update:

HaGeZi Pro added 247,196 domains. Pi-hole updates every list on its own once a week (a job inside the container, early on Sunday morning). The extra list costs some memory:
| Blocklists | Domains | Memory (docker stats) |
|---|---|---|
| StevenBlack only (default) | 81,677 | 44.46 MiB |
| StevenBlack + HaGeZi Pro | 328,873 | 69.18 MiB |

More lists are not always better: every list you add is one more source of false blocks. When a name is blocked and you want to know why, ask Pi-hole:
docker exec pihole pihole -q pagead2.googlesyndication.com
pihole -q tells you which list blocks a name, and which line of it.Step 7: Groups and clients: extra rules for a child's phone
Every device starts in the Default group and gets the same blocking. To give one device extra rules, make a group, put the device in it, and attach the rules to the group. First, Groups, add "Kids":

Then Clients: pick the device's address, give it a name, and choose its groups. Keep Default ticked: your blocklists belong to the Default group (see the Group assignment column on the Lists page), so a device outside it gets none of them.

Watch out: the form keeps the groups you chose last. When we added the laptop and the TV right after the phone, they were saved in Kids too. Check the Group assignment column after each add, and fix a row with its own group box: untick Kids and press Apply.

Now the rule. Under Domains, RegEx filter, this expression matches TikTok's site, app and video names. Set the group to Kids only (untick Default), then Add to denied domains:
(\.|^)(tiktok|tiktokv|tiktokcdn)\.com$
The test machine at the phone's address gets 0.0.0.0 for TikTok; the laptop does not:

DNS rules stop the easy way in, not a determined teenager: a phone on mobile data, a VPN app or a browser with its own DNS over HTTPS goes around Pi-hole. Use the phone's own parental controls as well.
Step 8: Allow a site that stopped working
Sooner or later a list blocks something you need, often a link in an email that goes through a click-tracking name. Find it in the Query Log (the search box sits under the table) and press Allow on its row:

Pi-hole adds an exact allow rule for that name under Domains, with the comment "Added from Query Log", for the Default group. Before and after, from the laptop:

Step 9: Local DNS records: names for your server and devices
Pi-hole can answer for names on your own network. Use the home.arpa ending: it is reserved for home networks, so it never clashes with a real site. Under Settings, Local DNS Records, add pihole.home.arpa with the server's address:


Do the same for each device (we added laptop.home.arpa, kids-phone.home.arpa and tv.home.arpa). Pi-hole then also knows the name for each address, and the dashboard and the Query Log show names instead of numbers, as in the screenshot at the top of this guide.
Step 10: Back up and restore (Teleporter, then a full copy)
Teleporter, under Settings, saves your setup in one zip file: settings, groups, clients, domains and the list of lists. Ours was 25 KB. Read the warnings on the page: the file holds sensitive data (store it like a password, and export over HTTPS when you can), and the long-term query history is not in it.

We tested a real restore: deleted the pihole.home.arpa record, imported the zip on the right side of the same page, and checked again.


After an import, run gravity (Tools, Update Gravity, or docker exec pihole pihole -g) so Pi-hole downloads the lists again.
For a full copy, including the query history and the HTTPS key, copy the whole data folder. Pi-hole stops for the few seconds tar needs, so the databases are copied in a clean state, and starts again even if the copy fails. The files belong to the container's user, so tar needs sudo; the second line gives the file back to you and makes it private:
cd ~/pihole
docker compose stop && sudo tar -czf ~/pihole-backup-$(date +%F).tar.gz etc-pihole compose.yaml; docker compose start
sudo chown "$(id -u):$(id -g)" ~/pihole-backup-*.tar.gz && chmod 600 ~/pihole-backup-*.tar.gz && ls -lh ~/pihole-backup-*.tar.gz
Keep a copy off the server. We restored from this file for real: the commands replace the data folder with the one in the backup.
cd ~/pihole
docker compose down
sudo rm -rf etc-pihole && sudo tar -xzf ~/pihole-backup-*.tar.gz && ls
docker compose up -d
Production setup: the hardened compose file
The quick-start file works, but it leaves a few things open. This is the file we ended with, tested line by line:
services:
pihole:
image: pihole/pihole:2026.11.0
container_name: pihole
hostname: pihole
restart: unless-stopped
ports:
- "192.168.1.50:53:53/tcp"
- "192.168.1.50:53:53/udp"
- "192.168.1.50:80:80/tcp"
- "192.168.1.50:443:443/tcp"
environment:
TZ: America/New_York
FTLCONF_dns_listeningMode: ALL
FTLCONF_dns_reply_host_force4: "true"
FTLCONF_dns_reply_host_IPv4: 192.168.1.50
FTLCONF_ntp_sync_active: "false"
WEBPASSWORD_FILE: pihole_webpasswd
secrets:
- pihole_webpasswd
volumes:
- ./etc-pihole:/etc/pihole
cap_add:
- SYS_NICE
cap_drop:
- NET_RAW
mem_limit: 256m
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
secrets:
pihole_webpasswd:
file: ./pihole_password.txt- Ports on the LAN address: from step 1. Pi-hole does not listen on the server's other addresses.
FTLCONF_dns_reply_host_force4andFTLCONF_dns_reply_host_IPv4: Pi-hole answerspi.holewith the address the question arrived on, and inside Docker that is the container's own address. With these two lines,http://pi.hole/adminopens on every device that uses Pi-hole.FTLCONF_ntp_sync_active: "false": Pi-hole will not try to set the server's clock (the server keeps its own time), and theCAP_SYS_TIMEwarning goes away.cap_add: SYS_NICE: lets FTL raise its own priority, as the image's own example file allows. SettingFTLCONF_misc_nice: "-999"instead did not stop the warning in our test.cap_drop: NET_RAW: Pi-hole's Docker notes say FTL uses it for DHCP only. For the same reason the file does not addNET_ADMIN.mem_limit: 256m: a ceiling. A full gravity update ran inside it without being stopped.- Log rotation: Docker keeps at most three 10 MB log files instead of one that grows forever.
docker compose up -d
pi.hole points at the container's own address, which no device can reach. 3-4: with the two settings.We also tried security_opt: no-new-privileges:true, a common hardening line. With it, FTL cannot pick up the rights the image gives its program:

no-new-privileges, FTL starts without the rights the image gives it.DNS still answered in that test, but FTL ran without three of the rights it expects, so we left the line out. The checks on the final file:
docker compose ps --format "table {{.Name}}\t{{.Image}}\t{{.Status}}"
docker compose logs pihole --since 3m | grep -E "WARNING|ERROR" | cut -c1-160
docker top pihole -o pid,uid,comm
docker exec pihole id pihole
pihole user, not root. 5: pi.hole works and blocking too.One warning stays: Trying to free NULL pointer in readEnvValue(). It came with every start in our tests, also with the quick-start file, and nothing failed; it is printed by FTL while it reads its environment variables, not caused by a line of this file. Last, a full list update under the memory limit:
docker exec pihole pihole -g | tail -n 6
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}" pihole
docker inspect pihole --format "OOMKilled={{.State.OOMKilled}} restarts={{.RestartCount}}"
HTTPS for the admin page
Pi-hole also serves the admin page over HTTPS on port 443, with a certificate it makes for itself for the name pi.hole:
curl -sk -o /dev/null -w "%{http_code}\n" https://192.168.1.50/admin/login
echo | openssl s_client -connect 192.168.1.50:443 2>/dev/null | openssl x509 -noout -subject -issuer -enddate
pi.hole, valid until 11 January 2027.Browsers warn about a certificate like this, because no one they trust signed it. On your own network you can accept it once: the password still travels encrypted. The certificate is valid for 47 days, and the comments in pihole.toml say Pi-hole renews certificates it made itself two days before they expire. For a certificate without the warning, use a local certificate authority (local HTTPS with mkcert) and point webserver.tls.cert to a PEM file that holds both the certificate and its key.
Update Pi-hole in Docker
In Docker you do not update Pi-hole from inside the container: you change the image tag and start a new container on the same data. We tested it on a second install that started on 2026.10.1, with DNSSEC on and one local record:

- Read the release notes of the new tag (GitHub, docker-pi-hole).
- Make the full backup from step 10.
- Change the tag, pull and restart, then check the health and the versions:
sed -i 's|pihole/pihole:2026.10.1|pihole/pihole:2026.11.0|' compose.yaml && grep image: compose.yaml
docker compose pull --quiet && docker compose up -d
docker compose ps --format "table {{.Name}}\t{{.Image}}\t{{.Status}}"
docker exec pihole pihole version
docker image rm pihole/pihole:2026.10.1
The settings and the local name came through. Keep a date tag rather than latest: you decide when an update happens, and going back is one tag change plus your backup.
Troubleshooting
| What you see | Cause | Fix |
|---|---|---|
failed to bind host port 0.0.0.0:53/tcp: address already in use | systemd-resolved uses port 53 | Publish the ports on the server's LAN address (step 1) |
pi.hole does not open, or dig pi.hole gives 172.18.0.2 | Pi-hole answers with the container's address | FTLCONF_dns_reply_host_force4 and FTLCONF_dns_reply_host_IPv4 (production section) |
| The laptop or TV gets the kids' rules | The client form kept the groups of the last client | Fix the row in the Clients table, then press Apply (step 7) |
| A setting has a padlock and cannot be changed | It is set in compose.yaml | Change it there and run docker compose up -d |
CAP_SYS_NICE or CAP_SYS_TIME warnings | Docker does not give these rights by default | cap_add: SYS_NICE and FTLCONF_ntp_sync_active: "false" |
CAP_NET_BIND_SERVICE and CAP_CHOWN warnings | no-new-privileges in the compose file | Remove that line |
| "Please run gravity" after an import | Teleporter does not carry the downloaded lists | Tools, Update Gravity, or docker exec pihole pihole -g |
| A site broke after you added a list | One list blocks a name it needs | pihole -q name shows the list; Allow it from the Query Log (step 8) |
Frequently asked questions
Is Pi-hole free?
Yes. Pi-hole is free and open source, and the Docker image costs nothing. The project lives on donations; the login page has the link.
Do I need a Raspberry Pi for Pi-hole?
No. The name comes from the Raspberry Pi, but the Docker image runs on 64-bit and 32-bit Intel, AMD and ARM machines. Any small Linux machine that stays on will do; this guide used an Ubuntu server. What matters is a fixed address and a machine that does not sleep.
Which ports does Pi-hole use in Docker?
53 over TCP and UDP for DNS, 80 for the admin page and 443 for the admin page over HTTPS. Port 67/udp is only for Pi-hole's DHCP server and 123/udp only if you use it as a time server. Publish them on the server's LAN address, never on your router's internet side.
How much memory does Pi-hole need?
Very little. In our test it used 44.46 MiB with the default list and 69.18 MiB with 328,873 blocked domains, and a full list update ran inside a 256 MiB limit. A machine with 1 GB of RAM has plenty of room.
Why do I still see some ads?
Pi-hole blocks by name. Ads that come from the same name as the content cannot be blocked without breaking it, and YouTube is the best-known case: its ads come from the same servers as the videos. A device that uses another DNS server (mobile data, a VPN, Private DNS on Android or DNS over HTTPS in the browser) skips Pi-hole. If a device's address never shows in the Query Log, it is not using Pi-hole.
Can I use Pi-hole as my DHCP server in Docker?
You can, but it needs more: port 67/udp, the NET_ADMIN right, and either host networking or a DHCP relay on your router, because DHCP broadcasts do not cross Docker's bridge network. For most homes it is simpler to keep the router's DHCP and only change its DNS server, as in step 3.
Can I put Pi-hole on the internet to use it away from home?
No. Do not forward port 53 or the admin ports on your router. An open DNS server gets abused for attacks on others, and the admin page should never face the internet. To use Pi-hole on the go, connect home through a VPN such as Tailscale and use Pi-hole's address as your DNS server there.
Related guides
- Setting DNS on Android: Private DNS, Wi-Fi IPs, and mobile data
- Quad9 DNS (9.9.9.9): Servers, IPv6, Private DNS, DoH Setup and Quad9 vs Cloudflare, Tested
- Tailscale 101: What It Is, Setup on Linux, SSH, Exit Node and Docker (2026)
- Local HTTPS with mkcert: Fix NET::ERR_CERT_AUTHORITY_INVALID for Self-Hosted Apps and Synology
- Install Docker Compose on Ubuntu using Docker’s repository
- How to Install Home Assistant with Docker Compose: Port 8123, Synology and Cloudflare Tunnel (2026)
Sources
- docker-pi-hole 2026.11.0 release notes (GitHub)
- Pi-hole on Docker Hub
- Pi-hole docs: Docker configuration and capabilities
- Pi-hole docs: Docker upgrading and persistence
- Pi-hole FTL v6.9 release notes (security fixes)
- HaGeZi DNS blocklists
- StevenBlack hosts
- RFC 8375: Special-Use Domain home.arpa
- Docker docs: port publishing
Leave a comment
Your email address will not be published. Required fields are marked *
