DockerDNS is a small DNS server for Docker that resolves:
<container-name>.<domain>
to the IP address of the running Docker container with that exact name.
Example:
sabnzbd.domain.local -> IP of the sabnzbd container
It is intended for setups where Docker already has stable container names, but you want a private DNS suffix on top without adding labels, reverse proxies, or a full service discovery stack.
- Watches the Docker API on demand by container name
- Resolves exact single-label names such as
plex.domain.local - Returns the container IP from a preferred Docker network if configured
- Supports both UDP and TCP DNS on port
53 - Returns
NXDOMAINwhen the name does not match a running container
- It does not watch Docker events or build a zone file
- It does not expose wildcard or multi-label routing
- It does not do reverse proxying
- It does not join multiple Docker hosts into one DNS namespace
| Variable | Default | Description |
|---|---|---|
DOMAIN |
domain.local |
DNS suffix to match |
DOCKER_NETWORK |
empty | Preferred Docker network when a container has multiple IPs |
LISTEN_ADDR |
:53 |
Bind address for the DNS server |
TTL |
30 |
TTL for returned DNS records in seconds |
- Query names must exactly match
container.domain - Only one label before the domain is accepted
sabnzbd.domain.localworksapi.sabnzbd.domain.localdoes not- Matching is case-insensitive
docker run -d \
--name dockerdns \
-e DOMAIN=domain.local \
-e DOCKER_NETWORK=appnet \
-p 53:53/udp \
-p 53:53/tcp \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/abyssal-labs/dockerdns:latestservices:
dockerdns:
image: ghcr.io/abyssal-labs/dockerdns:latest
container_name: dockerdns
environment:
DOMAIN: domain.local
DOCKER_NETWORK: appnet
TTL: "30"
ports:
- "53:53/udp"
- "53:53/tcp"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stoppedA ready-to-use example is also included in docker-compose.yml.
dig @127.0.0.1 sabnzbd.domain.local
dig @127.0.0.1 plex.domain.local
dig @127.0.0.1 AAAA jellyfin.domain.local- If
DOCKER_NETWORKis set and the container is attached to it, DockerDNS uses that network IP - Otherwise it returns the first usable IP found across attached networks
- If the query is
A, only IPv4 answers are returned - If the query is
AAAA, only IPv6 answers are returned
DockerDNS needs access to the Docker socket because it resolves names by inspecting containers at query time:
/var/run/docker.sock
Treat it as a privileged component and run it only on trusted hosts.
go build .
docker build -t dockerdns:latest .Repository: abyssal-labs/dockerdns