Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description

Resolvable - Docker DNS resolver

A simple DNS server to resolve names of local Docker containers.

resolvable is intended to run in a Docker container:

docker run -d \
    --hostname resolvable \
    -v /var/run/docker.sock:/tmp/docker.sock \
    -v /etc/resolv.conf:/tmp/resolv.conf \
    mgood/resolvable

The docker.sock is mounted to allow resolvable to listen for Docker events and automatically register containers.

resolvable can insert itself into the host's /etc/resolv.conf file by mounting this file to /tmp/resolv.conf in the container. When starting, it will insert itself as the first nameserver in the file, and remove itself when shutting down.

Systemd integration

On systems using systemd, resolvable can integrate with the systemd DNS configuration. Instead of mounting /etc/resolv.conf, mount the systemd configuration path /run/systemd and the DBUS socket as follows:

docker run -d \
    --hostname resolvable \
    -v /var/run/docker.sock:/tmp/docker.sock \
    -v /run/systemd:/tmp/systemd \
    -v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
    mgood/resolvable

resolvable will generate a systemd network config, and then use the DBUS socket to reload systemd-networkd to regenerate the host's /etc/resolv.conf.

Container Registration

resolvable provides DNS entries <hostname> and <name>.docker for each container. Containers are automatically registered when they start, and removed when they die.

For example, the following container would be available via DNS as myhost and myname.docker:

docker run -d \
    --hostname myhost \
    --name myname \
    mycontainer

DNS Forwarding

resolvable also supports forwarding DNS queries to other containers providing DNS servers. This integrates well with tools like Consul or SkyDNS that offer a DNS endpoint for service discovery.

Containers configured with the DNS_RESOLVES environment variable are registered in resolvable to forward DNS queries for any domains listed.

To run an example consul container, supporting DNS queries for the .consul domain on port 8600:

docker run -d \
    -e DNS_RESOLVES=consul \
    -e DNS_PORT=8600 \
    -p 8600/udp \
    consul

DNS_RESOLVES must contain least one domain to forward to this container. Multiple values can be provided as a comma-separated list.

DNS_PORT is optional, and defaults to 53.

Interface Addresses

resolvable also provides a DNS entry for the Docker bridge interface address, usually docker0. This can be used to communicate with services with a known port bound to the Docker bridge.

See this article on Docker network configuration for additional details on the Docker bridge interface.

Docker Pull Command
Owner
mgood
Source Repository

Comments (2)
mgood
2 years ago

@bonitao: searching for the error message in your comment, a few results come up indicating that you've passed a string for the "volumes" value, when it expects an "array", which Compose (Fig) interprets badly:
https://github.com/docker/compose/issues/340

I just noticed this comment, since Docker Hub doesn't alert me on updates. In the future you can use the link to the Github project page in the sidebar to file issues for support.

bonitao
2 years ago

Very interesting idea. Having per host dns resolution would simplify a lot my setup. Even docker0 provides a lot of value, and I searched for something with this functionality for a lot for time. Thanks a lot for the work.

I gave it a quick try, and it works as expected when ran using docker run as you instruct. But I need to call it from within docker-compose, and that is failing as follows (notice this is boot2docker on mac):

Compose version 1.2.0rc4
Docker base_url: https://192.168.59.103:2376
Docker version: KernelVersion=3.18.11-tinycore64, Arch=amd64, ApiVersion=1.18, Version=1.6.0, GitCommit=4749651, Os=linux, GoVersion=go1.4.2
docker containers <- (all=True)
docker containers -> (list with 1 items)
Creating davi_resolvable_1...
docker containers <- (all=True)
docker containers -> (list with 1 items)
docker create_container <- (name=u'davi_resolvable_1', image=u'mgood/resolvable:latest', hostname='resolvable', host_config={'Binds': ['/Users/davi/code/idea/idf::rw'], 'PortBindings': {}, 'NetworkMode': u'bridge', 'Links': [], 'VolumesFrom': []}, volumes={u'a': {}, u'': {}, u'c': {}, u'e': {}, u'd': {}, u'k': {}, u'm': {}, u'/': {}, u'n': {}, u'p': {}, u's': {}, u'r': {}, u'u': {}, u'o': {}, u'v': {}, u'.': {}, u't': {}}, detach=False)
docker create_container -> {u'Id': u'd9a7d3694220637944ec8bd0262cd9617ddb1c07ccad777df9e97f59bd70eccb',
u'Warnings': None}
docker inspect_container <- (u'd9a7d3694220637944ec8bd0262cd9617ddb1c07ccad777df9e97f59bd70eccb')
docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [],
u'Config': {u'AttachStderr': True,
u'AttachStdin': False,
u'AttachStdout': True,
u'Cmd': None,
u'CpuShares': 0,
u'Cpuset': u'',
u'Domainname': u'',
u'Entrypoint': [u'/bin/resolvable'],
...
docker start <- (u'd9a7d3694220637944ec8bd0262cd9617ddb1c07ccad777df9e97f59bd70eccb')
Cannot start container d9a7d3694220637944ec8bd0262cd9617ddb1c07ccad777df9e97f59bd70eccb: [8] System error: open /proc/self/fd: no such file or directory

Any ideas on what might be going on?