Time to read: 3 min read
Create a docker-compose.yml
file:
version: "3"
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
restart: unless-stopped
ports:
- "53:53/tcp"
- "53:53/udp"
- "8080:80"
- "8443:443"
environment:
TZ: "Asia/Dhaka"
WEBPASSWORD: "changeme"
volumes:
- "./etc-pihole/:/etc/pihole/"
- "./etc-dnsmasq.d/:/etc/dnsmasq.d/"
dns:
- 127.0.0.1
- 1.1.1.1
cap_add:
- NET_ADMIN
Then run:
docker compose up -d
Port 53 is critical for DNS. Run this to check if it's already in use:
sudo lsof -i :53
If you see something like systemd-resolved
or named
, you need to free that port.
On most Linux distros, systemd-resolved
binds to port 53 by default.
To disable it:
sudo systemctl disable --now systemd-resolved
Also replace the symlink for /etc/resolv.conf
:
sudo rm /etc/resolv.conf
echo "nameserver 127.0.0.1" | sudo tee /etc/resolv.conf
(You can also add a fallback like 8.8.8.8
if needed.)
To apply ad blocking to your whole network:
192.168.1.10
)8.8.8.8
)Now all devices will query Pi-hole for DNS.
Setting up local DNS allows you to:
nas.local
, printer.lan
, etc.)movie.ashraful.dev β 192.168.10.10
nas.lan β 192.168.10.20
ping movie.ashraful.dev
If it resolves, you're all set!
systemd-resolved
if it blocks port 53.Enjoy ad-free browsing across your entire network! π§ π‘οΈ