Skip to content

dokku/coredns-docker

coredns-docker

A CoreDNS plugin that serves DNS records for containers running on the local Docker daemon.

Installation

Install from a published release on the GitHub releases page:

# Linux amd64 — pick the binary that matches your platform/arch
curl -fsSL -o coredns-docker \
    https://github.com/dokku/coredns-docker/releases/latest/download/coredns-docker-linux-amd64
chmod +x coredns-docker
sudo mv coredns-docker /usr/local/bin/

Or build a single binary from source (requires Go):

make build-local

This produces ./coredns-docker-local in the repository root. See docs/installation.md for Debian packages, cross-platform builds, and the Docker image.

Basic usage

Create a minimal Corefile that serves the docker. zone on port 1053:

docker:1053 {
    docker {
        zone docker.
    }
}

Start CoreDNS with that Corefile:

coredns-docker -conf Corefile

Start any Docker container and query it by name:

docker run -d --name web nginx
dig @127.0.0.1 -p 1053 web.docker +short
# → 172.17.0.2

The plugin watches Docker events, so starting, stopping, or restarting containers updates the available names with no need to restart CoreDNS.

Documentation

  • Getting Started -- install, first Corefile, first query
  • Installation -- release binaries, Debian packages, source builds, and Docker image
  • DNS Basics -- a short primer on zones, A/AAAA, SRV, TXT, CNAME, PTR records, and TTLs
  • Configuration -- every Corefile option, stale mode, reverse zones, and the synthetic SOA/NS
  • Docker Labels -- hostname, cname, txt, srv, and wildcard labels
  • Metrics -- every Prometheus metric the plugin exposes
  • Testing -- unit, integration, and end-to-end test targets
  • Linux with systemd -- route docker. queries via systemd-resolved and run CoreDNS as a service
  • macOS with /etc/resolver -- route docker. queries via the macOS resolver
  • Examples -- runnable docker compose + Corefile setups for every feature

License

MIT

About

Coredns plugin responding with A and SRV docker container records

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors