DNS for containers
Use this setup when you run many containers and need DNS logs that are easier to attribute to a specific service.
Problem
Section titled “Problem”In a common setup, one host runs many containers and forwards DNS to a network resolver like Pi-hole or AdGuard Home.
Without per-container DNS routing, queries from all containers are grouped together in one bucket. That makes malicious or abnormal lookups harder to trace to a single service.
Solution
Section titled “Solution”Run one AdGuard Home container as the DNS endpoint for your other containers.
Then point reverse DNS upstream to the Docker DNS on the host, so container names appear instead of raw IPs.

High-level flow:
-
Create a bridge network with a static subnet for your stack.
-
Run AdGuard Home with a fixed IP in that subnet.
-
Assign static IPs to the remaining containers.
-
Set each container
dnsto the AdGuard Home static IP. -
Add
depends_onso services start after AdGuard Home.docker-compose.yaml networks:internal:driver: bridgeipam:config:- subnet: 172.20.0.0/16services:agh:image: adguard/adguardhomecontainer_name: aghvolumes:- /path/to/agh/conf:/opt/adguardhome/conf- /path/to/agh/work:/opt/adguardhome/worknetworks:internal:ipv4_address: 172.20.20.20ports:- 13080:80- 13000:3000someapp:networks:internal:ipv4_address: 172.20.0.2dns: 172.20.20.20depends_on:- agh
AdGuard Home configuration
Section titled “AdGuard Home configuration”Complete initial setup on port 13000, then use port 13080 for the web UI.
General settings
Section titled “General settings”Go to Settings > General settings.
- Block domains using filters and hosts files: disabled
- Enable log: enabled
- Query logs rotation:
90days - Ignored domains:
||your-private-domain.tld^ - Enable statistics: enabled
- Statistics retention:
90days - Ignored domains:
||your-private-domain.tld^
DNS settings
Section titled “DNS settings”Go to Settings > DNS settings.
- Upstream DNS servers:
127.0.0.11 - Private reverse DNS servers:
127.0.0.11:53 - Use private reverse DNS resolvers: enabled
- Rate limit:
0