docker

package module
v0.0.0-...-90637ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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 pull the multi-arch image from Docker Hub:

docker pull dokku/coredns-docker:latest

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

Documentation

Index

Constants

View Source
const DefaultTTL = uint32(30)

DefaultTTL is the default TTL for DNS records.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerInspector

type ContainerInspector interface {
	ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)
}

ContainerInspector is an interface for inspecting containers.

type Docker

type Docker struct {
	Next plugin.Handler

	Fall fall.F
	// contains filtered or unexported fields
}

Docker is a plugin that serves records for Docker containers

func (*Docker) Name

func (d *Docker) Name() string

Name implements the Handler interface.

func (*Docker) Ready

func (d *Docker) Ready() bool

Ready signals when the plugin is ready for use.

func (*Docker) ServeDNS

func (d *Docker) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

type GenerateRecordsInput

type GenerateRecordsInput struct {
	// Client is the Docker client to use.
	Inspector ContainerInspector
	// Containers is the list of containers to generate records for.
	Containers []container.Summary
	// Zones is the list of domains to generate records for.
	Zones []string
	// LabelPrefix is the label prefix to generate records for.
	LabelPrefix string
	// Networks is the list of networks to generate records for.
	Networks []string
	// HostMode enables host-bound IP/port resolution instead of container IPs.
	// When true, A/AAAA and SRV records are derived from each container's
	// published host port bindings (NetworkSettings.Ports).
	HostMode bool
	// HostModePTR enables PTR record emission while HostMode is active.
	// Off by default because multiple containers may share a host IP
	// (especially the loopback fallback), making reverse lookups noisy.
	HostModePTR bool
	// NameTemplates are Go text/templates that synthesize additional
	// names for each container from its Docker labels. Each template is
	// evaluated independently per container and any non-empty result
	// joins the container's name set alongside container name, network
	// aliases, DNSNames, Compose project.service, and hostname labels.
	NameTemplates []*template.Template
}

GenerateRecordsInput is the input for the generateRecords function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址