brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Guide: install Pi-hole on Ubuntu, with the script or with Docker Compose

install Pi-hole on Ubuntu, with the script or with Docker Compose

Guide docker

4 steps 4 min read

A network-wide ad blocker for every phone, TV and laptop at home is one small Ubuntu box away. I run AdGuard Home myself, so I look at Pi-hole as the well-known alternative, and the install is short either way. Two routes: the official script, or Docker Compose. Pi-hole v6 is the version I mean here, and WunderTech checked both routes against it in October 2026.

Time
4 min
Steps
4
Updated
19 Nov 2026

You will learn

  • Route 1: the official script
  • Route 2: Docker Compose
  • Point your network at it
  • Check that it works, and where it br…

What you need

An Ubuntu machine that stays on (a Pi, a mini PC, a VM) with a fixed address. Give it a DHCP reservation in your router, or a static IP, because every device will ask it for DNS. Docker is only needed for the second route.

Step 1 of 4: Route 1: the official script

This is the route the Pi-hole docs list first. They also point out that piping a script into bash means you cannot read it first, so I would download it and look before running it:

wget -O basic-install.sh https://install.pi-hole.net
less basic-install.sh
sudo bash basic-install.sh

The installer walks you through screens: the network interface, an upstream DNS provider, a blocklist, query logging and a privacy level. One trap WunderTech mentions: on the “Static IP Needed” screen the default button is Exit, so choose Continue once your address is fixed. The same write-up says the installer on Ubuntu turns off the systemd-resolved stub listener for you, so there is no port 53 fight on this route. That part is the blogger’s report, not something I found in the docs.

At the end, set your admin password yourself. WunderTech saw it left as “NOT SET” on one machine:

sudo pihole setpassword

Then open http://<ip-of-the-box>/admin.

Step 2 of 4: Route 2: Docker Compose

I like this one when the box already runs other containers. The compose file below follows the example in the official docker-pi-hole README, trimmed down, with the web port moved to 8080 as WunderTech does so it does not collide with anything else:

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "8080:80/tcp"
    environment:
      TZ: 'Europe/Amsterdam'
      FTLCONF_webserver_api_password: 'pick-your-own'
      FTLCONF_dns_listeningMode: 'ALL'
    volumes:
      - './etc-pihole:/etc/pihole'
    restart: unless-stopped

In v6 the password variable is FTLCONF_webserver_api_password; the old WEBPASSWORD from v5 no longer sets it (WunderTech). And with Docker’s default bridge network the README says the listening mode should be ALL. Add cap_add: NET_ADMIN only if Pi-hole will also be your DHCP server.

Ubuntu may already have port 53 taken by systemd-resolved, and then the container will not start. WunderTech’s fix, which is a blogger method and not from the Pi-hole docs, switches off the stub listener. Look at what it does before you paste it, because it replaces /etc/resolv.conf:

sudo mkdir -p /etc/systemd/resolved.conf.d
printf "[Resolve]\nDNSStubListener=no\n" | sudo tee /etc/systemd/resolved.conf.d/no-stub.conf
sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolved

Then start it and open http://<ip-of-the-box>:8080/admin:

docker compose up -d

Updating works differently here: pihole -up is disabled in the container, so run docker compose pull and then docker compose up -d again.

Step 3 of 4: Point your network at it

Nothing is blocked until devices use it. My advice is the router’s DHCP settings: put the Pi-hole’s IP in the DNS field, and every device picks it up. With only one Pi-hole, do not add a public DNS server as the second one, because devices will happily use it and the ads walk straight back in.

Step 4 of 4: Check that it works, and where it breaks

Renew the connection on a phone, open a page full of ads, then look at the query log in the admin page. Queries from that phone should show up there. If they do not, the device still uses another DNS server. Some smart TVs and cameras have a hardcoded one and ignore your router, and Pi-hole cannot do anything about those (WunderTech). Do not forward these ports through your router to the internet either.

Further reading

Link