Skip to main content

Update BIND nameserver zone with Docker hosts via DNS Updates.

Project description

Update BIND nameserver zone with Docker hosts via DNS Updates.


Docker HostDNS can be run by docker-hostdns wrapper script or directly with python -m docker_hostdns.

usage: docker-hostdns [-h] [--zone ZONE] [--dns-server DNS_SERVER]
                   [--dns-key-secret DNS_KEY_SECRET]
                   [--dns-key-name DNS_KEY_NAME] [--daemonize PIDFILE]
                   [--verbose] [--syslog]

Update BIND nameserver zone with Docker hosts via DNS Updates.

optional arguments:
  -h, --help            show this help message and exit
  --zone ZONE           Dns zone to update, defaults to "docker".
  --dns-server DNS_SERVER
                        Address of DNS server which will be updated, defaults
  --dns-key-secret DNS_KEY_SECRET
                        DNS Server key secret for use when updating zone. Use
                        '-' to read from stdin.
  --dns-key-name DNS_KEY_NAME
                        DNS Server key name for use when updating zone.
  --name NAME           Name to differentiate between multiple instances inside
                        same dns zone, defaults to current hostname.
  --daemonize PIDFILE, -d PIDFILE
                        Daemonize after start and store PID at given path.
  --verbose, -v         Give more output. Option is additive, and can be used
                        up to 3 times.
  --syslog              Enable logging to syslog.

The --daemonize options is only available when you have installed python-daemon3 package.

Example named.conf zone configuration with key auth:

include "/etc/bind/docker.key";

zone "docker" in {
    type master;
    file "/var/bind/dyn/";
    allow-update {
      key "docker-key";

docker.key can be generated by:

rndc-confgen -a -c docker.key -k docker-key

And then:

echo 'my base64 key secret' | docker-hostdns --dns-key-name docker-key --dns-key-secret -

Host names

Host name is created by using container name and slugifying & trimming it. So /example2::docker will result with example2-docker. In case of name duplication a “-<number>” will be appended, resulting with eg. example2-docker-1

Following dns records are created for each container, given example hostname and docker zone:

  • IPv4: example.docker
  • IPv4: *.example.docker
  • IPv6: example.docker
  • IPv6: *.example.docker
  • TXT: _container_<name>.docker with container name as value and instance name as <name>

TXT record is used for keeping track of added hosts so when app is stopped or resumed it keeps its state.

Custom host names

You can set custom host name by using container label pl.glorpen.hostname, its content will be used as container name.


  • it is now possible to run multiple instances in single dns zone #2 (dvenza)
  • added option to override default instance name for use in txt records


  • possible breaking change: changed dnspython3 package to just dnspython as Py3 is now supported


  • host names are now allowed to have dots in them


  • added tests
  • added proper domain names coversion
  • added a way to keep track of hosts when adding & removing containers


  • fixed error when handling disconnection event without earlier connect one
  • added app exception logging

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for docker-hostdns, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size docker_hostdns-1.1.1-py3-none-any.whl (13.1 kB) File type Wheel Python version 3.6 Upload date Hashes View
Filename, size docker-hostdns-1.1.1.tar.gz (10.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page