Each directory in this folder is a runnable demonstration of a specific feature. Every example contains a docker-compose.yml for the demo containers and a Corefile for CoreDNS. The CoreDNS binary runs on the host and serves DNS on 127.0.0.1:1053.
-
Install the plugin once (see ../installation.md). The commands below assume
coredns-dockeris on yourPATH. If you built withmake build-local, substitute../../../coredns-docker-localor add the project root to yourPATH. -
cdinto the example directory. -
In one terminal, start CoreDNS with the example's
Corefile:coredns-docker -conf Corefile
-
In another terminal, start the demo containers:
docker compose up -d
-
Run the
digcommand listed at the top of the example'sdocker-compose.ymlto verify. -
When you are done, stop the containers and CoreDNS:
docker compose down # then Ctrl-C the CoreDNS terminal
Why run CoreDNS on the host and services in Compose? The plugin needs access to /var/run/docker.sock to watch containers. Running CoreDNS on the host avoids any container-in-container DNS bootstrapping issues and keeps the examples minimal. If you would rather run CoreDNS in Compose too, build a local image from Dockerfile.hub and add a service that mounts the socket (see ../installation.md).
| Directory | Demonstrates |
|---|---|
| 01-basic | Default zone docker., no labels, resolving a container by its name |
| 02-custom-hostname | hostname label with multiple comma-separated names |
| 03-cname | cname label aliasing a container to an external name |
| 04-txt-records | Plain txt and keyed txt.KEY labels with multi-string values |
| 05-srv-records | srv._tcp._http labels and SRV queries |
| 06-wildcard | wildcard=true label and *.web.docker. matching |
| 07-host-mode | host_mode directive for CoreDNS running outside Docker |
| 08-network-filtering | networks whitelist ignoring containers on other networks |
| 09-multiple-zones | Serving multiple zones from one Corefile |
| 10-fallthrough | fallthrough to the forward plugin for upstream resolution |
| nginx-integration | nginx reverse proxy resolving backends via CoreDNS |