How to Run Pi-hole on a Mini PC with Docker Compose

Every phone, TV, and laptop in your house asks a DNS server where websites live, and many of those requests are for ad and tracking domains. Pi-hole sits in the middle and refuses to answer for the ones on its blocklists. Because it works for the whole network, one small mini PC can quiet ads on devices that can’t run an ad blocker at all, like smart TVs and game consoles.

This guide shows you how to run Pi-hole on a mini PC using Docker Compose, from freeing up port 53 to pointing your router at it. It assumes you already have Docker installed. If you don’t, start with our Docker Compose tutorial for beginners, and if you’re still choosing hardware, see our mini PC homelab guide for beginners.

What Pi-hole does (and what it doesn’t)

Pi-hole is a DNS server. When a device asks for the address of a domain on a blocklist, Pi-hole gives back a blank answer, so the ad never loads. Everything else is passed on to an upstream DNS provider you choose.

That has two consequences worth knowing up front. First, Pi-hole blocks by domain name, so it can’t remove ads that are served from the same domain as the content, such as many video ads. Second, it can occasionally block something you need, so you should expect to allow a few domains now and then. It reduces ads and trackers, but it isn’t a guarantee.

What you need

  • A mini PC running Linux with Docker and the Compose plugin installed.
  • A wired Ethernet connection. A DNS server that drops off the network will make your whole house feel like the internet is down.
  • Access to your router’s admin page.
  • A fixed IP address for the mini PC. Our guide to home network basics for homelab beginners explains how to set up a DHCP reservation.

Pi-hole itself is light. The official documentation lists modest requirements, and a low-power mini PC has plenty of room for it alongside other containers.

Step 1: Check whether port 53 is free

DNS uses port 53, and Pi-hole needs it. On Ubuntu, a service called systemd-resolved often occupies that port, which causes the most common error beginners hit: “address already in use.” Check what is listening:

sudo lsof -i -P -n | grep LISTEN

If you see systemd-resolve on port 53, it needs to step aside. If another program such as dnsmasq is listed, deal with that one instead, because the fix below won’t help. The Pi-hole community’s thread on what to do if port 53 is already in use covers this in detail.

Free the port from systemd-resolved

Open the resolver settings file:

sudo nano /etc/systemd/resolved.conf

Find the line #DNSStubListener=yes, remove the #, and change it to:

DNSStubListener=no

Many guides then repoint the system’s own resolver file so the mini PC can still look up names, and restart the service:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl restart systemd-resolved

Run the lsof command again. Port 53 should now be free. Note down what you changed, because you may want to undo it later. Undoing it means setting the line back to #DNSStubListener=yes (or deleting the line) and restarting the service.

Step 2: Create the Pi-hole folder

Following the same layout we used for other apps, give Pi-hole its own folder:

sudo mkdir -p /srv/docker/pihole
sudo chown -R $USER:$USER /srv/docker
cd /srv/docker/pihole

Step 3: Write the Compose file

Create a compose.yaml file:

nano compose.yaml

This is based on the example in the official Pi-hole Docker documentation, with the password moved into a separate file:

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: "America/New_York"
      FTLCONF_webserver_api_password: "${PIHOLE_PASSWORD}"
      FTLCONF_dns_listeningMode: "ALL"
    volumes:
      - "./etc-pihole:/etc/pihole"
    restart: unless-stopped

Change TZ to your own time zone so the query log shows the right times. Then create the .env file that holds your admin password, as described in the “keeping passwords out of the file” section of our Compose tutorial:

nano .env
PIHOLE_PASSWORD=choose-a-long-unique-password

What the important lines do

  • Port 53 (TCP and UDP) is where DNS requests arrive.
  • Ports 80 and 443 serve the web dashboard. If something else already uses port 80, change the left-hand number, for example "8080:80/tcp", and use :8080 in your browser.
  • FTLCONF_webserver_api_password sets the dashboard password. This is the Pi-hole v6 setting name, so older tutorials that use WEBPASSWORD are out of date.
  • FTLCONF_dns_listeningMode: “ALL” is what the official documentation recommends for Docker’s default network, so Pi-hole answers requests that arrive through the container network.
  • The etc-pihole volume keeps your settings and lists on the mini PC, so they survive updates and container rebuilds.

The official example also shows optional extra permissions (NET_ADMIN, SYS_TIME, SYS_NICE). They’re only needed if you want Pi-hole to act as your DHCP server or time server, so you can leave them out for a standard setup.

Step 4: Start Pi-hole

docker compose up -d
docker compose logs -f

Wait until the logs settle, then press Ctrl+C to stop watching. Open a browser on another computer and go to http://YOUR-SERVER-IP/admin. Log in with the password from your .env file.

If the container exits straight away, read the logs. A port 53 error means Step 1 isn’t finished. A port 80 error means you need the alternative port mapping above.

Step 5: Test it before touching the router

Before you send the whole house to Pi-hole, make sure it answers. From another computer, run:

nslookup example.com YOUR-SERVER-IP

You should get an answer that includes an IP address. If it times out, check that the container is running with docker compose ps and that no firewall on the mini PC is blocking port 53. This is a good habit: test one device first, so a mistake doesn’t take down everyone’s internet.

For a safe trial, set the DNS server on just one laptop to your Pi-hole’s address and browse for a while. Check the query log in the dashboard to see requests coming in.

Step 6: Point your network at Pi-hole

Once you’re happy, tell your router to hand out the Pi-hole address as the DNS server. Look in your router’s DHCP or LAN settings for a DNS server field and enter your mini PC’s IP address. Router menus differ, and some ISP-supplied routers don’t allow this change, so check your router’s manual. If yours won’t let you, you can set the DNS server on each device by hand instead.

Three things catch people out here:

  1. Devices keep their old DNS settings until their lease renews. Reconnect to Wi-Fi, restart the device, or wait for the lease to expire.
  2. A second DNS server can quietly bypass Pi-hole. If you add a public server as the secondary, many devices will use it some of the time, and ads will slip through. If you want a backup, run a second Pi-hole rather than a public resolver.
  3. IPv6 can bypass it too. If your router also advertises its own IPv6 DNS server, devices may use that instead. Check your router’s IPv6 DNS settings if ads are still showing.

Remember that if the mini PC goes down, DNS goes down with it, and your family may notice before you do. Keep the machine on stable power and avoid rebooting it casually.

Choose your upstream DNS

Pi-hole needs somewhere to send the requests it doesn’t block. In the dashboard, open Settings and then DNS to pick an upstream provider. Different providers have different privacy policies, so read them before choosing. Whichever you pick, the provider can see which domains Pi-hole asks about, though not which device asked.

Add or adjust blocklists

Pi-hole ships with a default blocklist. You can add more under Lists in the dashboard, then update the list database (called gravity) from the dashboard’s tools. Start with just the defaults for a week. Adding many aggressive lists at once is the fastest way to break websites and not know which list caused it.

When a page or app stops working, check the query log for a blocked domain around that moment, then allow it from the dashboard. Keep a short note of every domain you allow.

Back up and update

The etc-pihole folder holds your settings and lists. Include /srv/docker/pihole in your routine, as described in our homelab backup strategy for beginners. Pi-hole is easy to rebuild, but retyping your allow list is annoying.

To update:

docker compose pull
docker compose up -d

Read the release notes first for major version changes. If you’d rather not get surprise upgrades, pin the image to a specific version tag from the project’s page instead of latest.

Troubleshooting common problems

The container won’t start because port 53 is in use

Something else holds the port. Run the lsof command from Step 1 and find out what. If it’s systemd-resolved, finish the steps above and restart it.

The dashboard loads but nothing is blocked

Your devices aren’t using Pi-hole yet. Check the query log. If no queries appear, the device is using a different DNS server, so renew its lease and check for IPv6 or secondary DNS settings.

The whole network lost internet

The Pi-hole machine is probably off or the container stopped. Run docker compose ps. As an emergency fix, change the DNS setting on your router back to automatic.

The mini PC itself can’t resolve names after changing systemd-resolved

The system’s resolver file may be pointing at the wrong place. Check /etc/resolv.conf and confirm it lists a working DNS server.

A website or app is broken

Look for a blocked domain in the query log and allow it. If many things break, remove recently added blocklists.

Frequently asked questions

Is Pi-hole free?

Yes. It’s free and open source. You only pay for the hardware and electricity.

Does Pi-hole slow down my internet?

It adds a small step to each DNS lookup, but results are cached, and on a home network the difference is usually not noticeable. Blocking ads can even make pages feel quicker.

Can I run Pi-hole on a Raspberry Pi instead?

Yes, that’s the classic setup, and the Docker steps are similar. A mini PC is handy if you want to run other services on the same machine.

Does Pi-hole block YouTube ads?

Usually not. Those ads are served from the same domains as the videos, which DNS blocking can’t separate.

Can I run Pi-hole inside Proxmox?

Yes. A common approach is a small Linux virtual machine or container with Docker inside it. See our Proxmox vs Ubuntu Server comparison if you haven’t picked a platform.

Wrapping up

Running Pi-hole on a mini PC takes four moves: free port 53, write a short Compose file, test it on one device, then point your router at it. Keep a note of what you changed, avoid a public secondary DNS server, and back up the etc-pihole folder. Once it’s stable, it quietly blocks a lot of junk for every device in the house.

Sources