Run AdGuard Home in Docker: network-wide ad blocking and local DNS

Published

AdGuard Home is a DNS server that answers every DNS lookup on your network and refuses to resolve domains used for ads, trackers and malware. Because it works at the DNS level, it protects every device that uses it (phones, TVs, laptops, game consoles) without installing anything on them. It also doubles as a local DNS server, which is useful for giving your own services friendly names.

This guide covers the full setup in Docker: installation, freeing port 53, first-run configuration, pointing your network at it, tuning, security, backups and troubleshooting.

What you need

  • A Linux machine, VM or container that is always on, with Docker and Docker Compose installed
  • A fixed (static or reserved) IP address for that machine
  • Access to your router's DHCP and DNS settings

DNS is critical to everything on your network. If this machine goes down, devices that depend on it lose name resolution, so give it a stable home and plan for a fallback (covered below).

1. Free port 53

DNS uses port 53. On many Ubuntu and Debian systems, systemd-resolved already listens on 127.0.0.53:53 as a stub resolver, which stops the container from binding to the port. Check what is using it:

sudo ss -tulpn | grep ':53 '

If systemd-resolved shows up, disable only its stub listener:

sudo mkdir -p /etc/systemd/resolved.conf.d
sudo tee /etc/systemd/resolved.conf.d/adguardhome.conf > /dev/null <<'EOF'
[Resolve]
DNS=127.0.0.1
DNSStubListener=no
EOF
sudo mv /etc/resolv.conf /etc/resolv.conf.backup
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
sudo systemctl reload-or-restart systemd-resolved

The host itself will keep resolving names through the upstream servers that systemd-resolved knows about. Run the ss command again; port 53 should now be free.

2. Create the Compose file

Create a project folder, for example /opt/adguard, and add a compose.yaml:

services:
  adguardhome:
    image: adguard/adguardhome:latest
    container_name: adguardhome
    restart: unless-stopped
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "3000:3000/tcp"   # first-run setup wizard only
      - "8080:80/tcp"     # web interface after setup
    volumes:
      - ./work:/opt/adguardhome/work
      - ./conf:/opt/adguardhome/conf

Notes on the ports:

  • 53 (TCP and UDP): DNS itself. UDP handles most queries; TCP is used for large answers.
  • 3000: the setup wizard. You only need it for the first run.
  • 8080: the admin interface after setup. Change the left-hand number if 8080 is taken.
  • Other ports: AdGuard Home can also serve DNS-over-TLS (853), DNS-over-HTTPS (443) and run a DHCP server (67/68). Leave them out unless you actually need them.

Start it:

cd /opt/adguard
docker compose up -d
docker logs adguardhome

3. First-run setup

Open http://SERVER_IP:3000 in a browser and step through the wizard:

  1. Admin web interface: listen on all interfaces, port 80. This is the port inside the container, which you mapped to 8080 on the host.
  2. DNS server: listen on all interfaces, port 53.
  3. Create an admin account with a strong, unique password.

After you finish, the dashboard is at http://SERVER_IP:8080. You can now remove the 3000:3000 line from the compose file and run docker compose up -d again.

4. Configure upstream DNS

AdGuard Home does not know every domain itself. It forwards lookups to upstream resolvers. Open Settings → DNS settings and set:

  • Upstream DNS servers: encrypted servers keep your queries private from your ISP. For example:
https://dns.cloudflare.com/dns-query
https://dns.quad9.net/dns-query
  • Parallel requests: the fastest answer wins, which often lowers latency.
  • Bootstrap DNS servers: plain IP addresses AdGuard Home uses once to look up the hostnames of the encrypted upstreams (for example 1.1.1.1 and 9.9.9.9).
  • Rate limit: keep a sensible per-client limit as a basic protection against abuse.

Use Test upstreams to confirm they respond before you save.

5. Choose blocklists

Under Filters → DNS blocklists, the default AdGuard DNS filter is a good starting point. You can add more from the built-in list of common lists.

Start with one or two lists. More lists block more, but they also raise the chance of breaking a legitimate site, and the lists overlap heavily. If something breaks, the query log (below) shows you which rule blocked it, and you can add an exception under Filters → Custom filtering rules:

@@||example.com^

6. Point your network at it

There are two ways to use it:

  • Whole network: in your router's DHCP settings, set the DNS server handed out to clients to the AdGuard machine's IP. Devices pick it up when they renew their lease or reconnect.
  • Single device: set the DNS server in that device's network settings. This is the safest way to test before switching everything.

Be careful with a secondary DNS entry. If you list a public resolver as the second server, many devices will use it some of the time and skip your blocking. Either leave the second entry empty or run a second AdGuard Home instance.

Verify it works from another machine:

nslookup example.com SERVER_IP
nslookup doubleclick.net SERVER_IP

The first should resolve normally. The second should return a blocked answer, often 0.0.0.0 or an NXDOMAIN, depending on your blocking mode.

7. Local names with DNS rewrites

Under Filters → DNS rewrites, you can map a hostname to an IP address, such as nas.home.example pointing to a local address. This is called split DNS: the same name resolves to a private address inside your network while public DNS answers with something else outside.

This is very useful when you run services behind a reverse proxy. Services reachable by name at home do not need traffic to leave your network and come back. Pick a domain you own for these names, and avoid made-up suffixes that could clash with real ones.

8. Use the query log

Query log shows every request, which client made it, and whether it was blocked, allowed or served from cache. It is the main troubleshooting tool. If a page misbehaves, find its domains in the log and check for blocked entries. Under Settings → General settings you can set how long logs and statistics are kept, which also limits how much history is stored about your devices.

9. Security checklist

  • Never expose port 53 to the internet. An open resolver can be abused for DDoS amplification. Make sure your router does not forward port 53 from the WAN side.
  • Keep the admin interface private. Use it only from your LAN or over a VPN. If you publish it, put it behind HTTPS and a second layer of authentication.
  • Use a strong admin password and keep the image updated.
  • Restrict who can query it. Under Settings → DNS settings → Access settings you can allow only your own subnets.
  • Do not expose the setup port 3000 after the wizard is done.

10. Updates and backups

Update the image with:

cd /opt/adguard
docker compose pull
docker compose up -d

All settings, rewrites, filters and statistics live in the conf and work folders next to the compose file. Copy those folders somewhere safe and you can restore the whole setup, even on a different machine.

Troubleshooting

  • Container will not start, "address already in use": something else holds port 53. Re-run the ss command from step 1.
  • Ads still appear on some devices: the device may be using its own DNS, such as a browser with DNS-over-HTTPS turned on, a smart TV with hard-coded resolvers, or an IPv6 DNS server your router advertises. Check the query log to see whether that device appears at all.
  • A site stopped working: look up its domains in the query log, then add an allow rule as shown above.
  • The whole network lost DNS: if the AdGuard machine is off, clients have nowhere to resolve names. Use a reserved IP, enable restart: unless-stopped, and consider a second instance for redundancy.
  • Slow first lookups: enable parallel requests and DNS caching in the DNS settings.

Summary

AdGuard Home in Docker gives you network-wide blocking, private upstream lookups and local DNS names from a single small container. Free port 53, run the compose file, finish the wizard, set sensible upstreams and lists, then point your router at it. Keep it off the public internet, back up the conf and work folders, and use the query log whenever something behaves oddly.

← All guides