Self-Host AdGuard Home with Docker: Network-Wide Ad Blocking
This tutorial was written with AI assistance from the project's official documentation. Verification status is stated at the end of the article.
What AdGuard Home does and what it needs
AdGuard Home is a DNS server that sinks ad and tracker domains into a black hole before your devices ever connect to them. Point your router's DHCP DNS at it once, and every phone, laptop, smart TV, and IoT plug on the network gets filtered. No client software, no per-device setup.
The web dashboard is where the real work happens: query logs, per-client rules, custom filter lists, upstream resolver choice (plain DNS, DoH, DoT, DNSCrypt), and a built-in DHCP server if you want AdGuard Home to hand out addresses too.
Under the hood it's a single Go binary with an embedded React frontend. No database, no cache service, no sidecar. The container needs two things: a writable directory for its config and query stats, and the DNS ports. That's it. The upstream project does not publish a minimum memory figure. In practice an idle instance serving a home network sits in the low tens of megabytes; memory grows with query-log retention and the number of filter lists you enable, so a box running a dozen large blocklists and keeping 90 days of stats will use noticeably more than a fresh install.
Prerequisites, ports, and volume constraints
You need Docker Engine 24+ with the Compose plugin, and a host with a static LAN IP. A domain is optional but recommended if you want HTTPS on the dashboard.
Ports matter more here than for a typical web app:
- 53/tcp and 53/udp — the actual DNS service. These must be reachable from your LAN clients, so they bind to all interfaces, not just localhost. If
systemd-resolvedordnsmasqalready holds port 53 on the host, stop it first (sudo systemctl disable --now systemd-resolved) or the container will fail to start. - 3000/tcp — the web dashboard and the first-run setup wizard. Bind this to
127.0.0.1and put a reverse proxy in front of it. - 67/udp and 68/udp — only if you enable the built-in DHCP server. Skip them otherwise; they conflict with any existing DHCP server on the network.
- 443/tcp and 853/tcp — only if you enable DNS-over-HTTPS or DNS-over-TLS serving from AdGuard Home itself.
Two named volumes hold all state: adguard_work for the config file and filter data, adguard_conf for the runtime config directory. Back these up and you can rebuild the container from scratch in a minute.
Production Docker Compose setup
Create the project directory and the environment file first. Generate a real password for the dashboard — the setup wizard will ask for it, and you should not reuse anything.
mkdir -p /opt/adguardhome && cd /opt/adguardhome cat <<'EOF' > .env TZ=UTC ADMIN_USER=admin ADMIN_PASSWORD_HASH= EOF # Generate a strong password and store it in your password manager. openssl rand -base64 24 Leave ADMIN_PASSWORD_HASH empty — AdGuard Home hashes the password itself during the first-run wizard. The variable exists so you can record which account you created.
Now the compose file:
cat <<'EOF' > compose.yml services: adguardhome: image: adguard/adguardhome:latest container_name: adguardhome restart: unless-stopped environment: TZ: ${TZ:-UTC} volumes: - adguard_work:/opt/adguardhome/work - adguard_conf:/opt/adguardhome/conf ports: # DNS — must be reachable from LAN clients - "53:53/tcp" - "53:53/udp" # Dashboard — localhost only, reverse proxy terminates TLS - "127.0.0.1:3000:3000/tcp" # Uncomment only if you enable the built-in DHCP server # - "67:67/udp" # - "68:68/udp" # Uncomment only if AdGuard Home serves DoH/DoT itself # - "443:443/tcp" # - "853:853/tcp" healthcheck: test: ["CMD", "/opt/adguardhome/AdGuardHome", "--version"] interval: 30s timeout: 5s retries: 3 volumes: adguard_work: adguard_conf: EOF docker compose up -d docker compose logs -f adguardhome The healthcheck is a liveness probe, not a DNS query test — it confirms the binary runs. For a real DNS check from the host: dig @127.0.0.1 -p 53 example.com.
If you're testing without a domain, temporarily expose the dashboard on the public interface by changing the port line to "3000:3000/tcp", or keep it on localhost and tunnel in:
ssh -L 3000:127.0.0.1:3000 user@your-vps Then open http://localhost:3000 and complete the setup wizard. It asks you to pick the admin interface port (leave it at 3000), set a username and password, and choose upstream DNS servers. Pick DoH or DoT upstreams — plain DNS upstreams leak your query stream to your ISP.
Reverse proxy, HTTPS, and first-run hardening
AdGuard Home's dashboard is a single-page app that talks to the backend over HTTP with a session cookie. It does not use WebSockets, so you don't need upgrade headers. What you do need:
- A large
client_max_body_sizeif you plan to upload custom filter lists or restore a config backup through the UI. 10 MB is a safe ceiling. -
X-Forwarded-ProtoandX-Forwarded-Forso the dashboard generates correct links and the query log shows real client IPs instead of the proxy's address. - No caching on
/control/API paths — stale responses will make the dashboard show wrong stats.
Nginx example:
server { listen 443 ssl http2; server_name dns.example.com; ssl_certificate /etc/letsencrypt/live/dns.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/dns.example.com/privkey.pem; client_max_body_size 10m; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 90s; } location /control/ { proxy_pass http://127.0.0.1:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; add_header Cache-Control "no-store"; } } Caddy equivalent, if you prefer automatic certificates:
dns.example.com { reverse_proxy 127.0.0.1:3000 { header_up X-Forwarded-Proto {scheme} } request_body { max_size 10MB } } First-run hardening. The setup wizard is open to anyone who can reach port 3000 until you finish it. Complete it immediately after docker compose up -d — don't leave the container running overnight with the wizard exposed. Once the admin account exists, the wizard is gone and the login page requires credentials. If you ever need to reset the password, stop the container, edit AdGuardHome.yaml inside the adguard_conf volume, and restart.
After setup, go to Settings → Encryption and enable HTTPS for the admin interface only if you're not terminating TLS at the proxy. Running both is redundant and a common source of redirect loops.
Updating, backups, and common pitfalls
Update:
cd /opt/adguardhome docker compose pull docker compose up -d docker image prune -f AdGuard Home writes its config on shutdown, so docker compose restart is safe. Avoid docker kill — you can lose the last few minutes of query stats.
Backup. Everything lives in two volumes. Stop the container first so the YAML is flushed, then archive:
docker compose stop adguardhome docker run --rm \ -v adguardhome_adguard_conf:/conf \ -v adguardhome_adguard_work:/work \ -v "$PWD":/backup \ alpine tar czf /backup/adguardhome-$(date +%F).tar.gz -C / conf work docker compose start adguardhome The volume names are prefixed with the Compose project name (the directory name by default), so verify with docker volume ls before scripting this. Restore is the reverse: stop, extract into the volumes, start.
Pitfalls from the docs and real deployments:
Port 53 is already taken. On Ubuntu and Debian,
systemd-resolvedlistens on 127.0.0.53:53 and will silently steal queries. The container starts but DNS resolution fails. Disable it or configure it to use AdGuard Home as its upstream. Check withsudo ss -ulpn | grep :53before you start.DNS-level blocking has hard limits. The README is explicit: YouTube and Twitch ads, and sponsored posts on Facebook, Twitter, and Instagram, share a domain with the content itself. DNS sinkholing cannot block them. Don't promise your users a fully ad-free internet — set expectations that this catches the tracking and display-ad layer, not in-stream video ads.
Query log growth. The dashboard keeps query stats in memory and on disk. On a busy network with a long retention window, the
adguard_workvolume grows steadily. Set a retention limit under Settings → General and monitordocker system dfmonthly.
Measured in our sandbox run: total memory 10.6 MB (sum of per-container peaks over a 30s idle window after startup) across 1 container; largest container 10.6 MB; published port(s) 53, 3000; HTTP probe returned 302. The run took 191.8s including the image download.
Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.
Originally published with full interactive benchmark metrics and server sizing notes at https://vpsfolio.pages.dev/self-host-adguard-home-docker/.