Sign inSign up

jamestalmage/container-dns

By jamestalmage

Updated over 1 year ago

A DNS server for your Docker bridge interfaces

Image
0

342

jamestalmage/container-dns repository overview

jamestalmage/container-dns


A DNS server that will resolve to the internal bridge addresses of a container. Useful if you are going to proxy requests to the container and don't want to statically configure ip addresses. DNS names will be based on the container name. It dynamically generates a hosts file at /etc/custom_hosts that you could bind mount to the hosts dir of a different dns server.

Usage

You must pass the docker sock to /var/run/docker.sock in order for the container to be able to query the docker api.

You should expose port 53 (tcp and udp) on the host.

The first option passed should be the --tld (top level domain) you want to use. The default is docker. The remaining arguments can just be a set of bridge names you want parsed.

By default, the address for a container on a given bridge will be [container_name].[bridge_name].[tld].

You can override the domain for individual bridges with the --domain flag. Note: the TLD is not appended when this flag is used, so you should include it in the domain.

docker container run -d --name container-dns -p 53:53 -p 53:53/udp jamestalmage/container-dns bridge 
# A container `foo` on the default `bridge` will be accessible at: foo.bridge.docker

docker container run ... container-dns -tld local bridge br0
# A container `foo` on the default `bridge` will be accessible at: foo.bridge.local
# A container `bar` on the `br0` bridge will be accessible at: bar.br0.local

docker container run ... container-dns -tld dockernet --domain mydomain.io bridge br0
# A container `foo` on the default `bridge` will be accessible at: foo.mydomain.io
# A container `bar` on the `br0` bridge will be accessible at: bar.br0.dockernet

Tag summary

Content type

Image

Digest

sha256:c14649520

Size

11.4 MB

Last updated

over 1 year ago

docker pull jamestalmage/container-dns