Package: docker-hostdns
Update BIND nameserver zone with Docker hosts via DNS Updates.UsageDocker HostDNScan be run bydocker-hostdnswrapper script or directly withpython-mdocker_hostdns.usage: docker-entrypoint [-h] [--zone ZONE] [--dns-server DNS_SERVER]
                         [--dns-key-secret DNS_KEY_SECRET]
                         [--dns-key-name DNS_KEY_NAME]
                         [--dns-key-alg {...}]
                         [--name NAME] [--network NETWORK] [--verbose]
                         [--syslog [SYSLOG]] [--clear-on-exit]

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
                        to 127.0.0.1
  --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
  --dns-key-alg {...}
                        DNS Server key algorithm for use when updating zone
  --name NAME           name to differentiate between multiple instances
                        inside same dns zone, defaults to current hostname
  --network NETWORK     network to fetch container names from, defaults to
                        docker default bridge, can be used multiple times
  --verbose, -v         give more output - option is additive, and can be used
                        up to 3 times
  --syslog [SYSLOG]     enable logging to syslog, defaults to "/dev/log", you
                        can provide path to unix socket or uri:
                        <tcp|udp|unix>://<path_or_host>[:<port>]
  --clear-on-exit       clear zone on exitThe--daemonizeoptions is only available when you have installedpython-daemon3package.Examplenamed.confzone configuration with key auth:include "/etc/bind/docker.key";

zone "docker" in {
    type master;
    file "/var/bind/dyn/docker.zone";
    allow-update {
      key "docker-key";
    };
};docker.keycan be generated by:rndc-confgen-a-cdocker.key-kdocker-keyAnd then:echo'my base64 key secret'|docker-hostdns--dns-key-namedocker-key--dns-key-secret-Host namesHost name is created by using container name and slugifying & trimming it. So/example2::dockerwill result withexample2-docker.
In case of name duplication a “-<number>” will be appended, resulting with eg.example2-docker-1Following dns records are created for each container, givenexamplehostname anddockerzone:IPv4:example.dockerIPv4:*.example.dockerIPv6:example.dockerIPv6:*.example.dockerTXT:_container_<name>.dockerwith 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 namesYou can set custom host name by using container labelpl.glorpen.hostname, its content will be used as container name.Docker ImageDocker image is available atglorpen/hostdns.
For help trydocker run--rm-itglorpen/hostdns:latest--help.Remember to mount/run/docker.sockinside container.Build image from GitHubgit clone <repo>cddocker-hostdns/docker build-t"<image name>" .Docker environment variablesDNS_SERVER:            address of DNS server which will be updated, defaults to127.0.0.1DNS_ZONE:              DNS zone to update, defaults todockerDNS_KEY_NAME:          DNS Server key name for use when updating zoneDNS_KEY_SECRET:        DNS Server key secret for use when updating zoneDNS_KEY_SECRET_FILE:   path of file with secret as its contentNAME:                  name to differentiate between multiple instances inside same dns zone, defaults to current hostnameNETWORK:               network to fetch container names from, defaults to docker default bridge, accepts multiple networks as comma delimited list (e.g.network1,network2,network3,..)VERBOSITY:             give more output, accepts0to3, defaults to0(equivalent to-v,-vv,-vvvarguments on the command line)SYSLOG:                enable logging to syslog, if settrueoryesdefaults to “/dev/log”, or you can provide path to unix socket or uri:<tcp|udp|unix>://<path_or_host>[:<port>]CLEAR_ON_EXIT:         clear zone on exit, defaults tofalse(acceptstrueoryes)Securing DNS secret keyTo secure secret key (thedns-key-secretoption) you can:passing its contents to env varDNS_KEY_SECRETsetting env varDNS_KEY_SECRET_FILEto path of file with secret as its contentOption--dns-key-secret-will be then automatically prepended and secret key piped to docker-hostdns process.Working with docker-composeWhen usingdocker-composefor development you can create custom docker network and use it as
domain names source.To do this, create docker network withdocker network createexample-dnsand then runDocker HostDNSwith--networkexample-dnsargument.Next, with exampledocker-compose.yml:version:'2.2'services:app:image:examplelabels:pl.glorpen.hostname:examplenetworks:default:~dns:~networks:dns:external:truename:example-dnsyou can start container that would be accessible by host asexample.dockerdomain.2.4.0added dns server name resolvingadded key algorithm parameter for update request signing2.3.0configure travisslim docker imagefixed and added more testsadded more environment variables2.2.0added environment variables for docker image2.1.0fixed docker entrypoint exit signal handlingadded clean-on-exit option to clear used dns zone2.0.0added Docker imagewatched network interfaces can be now specified by usercontainer name deduplication now only drops duplicate namessingle container can have multiple aliasesshort id and other container aliases are now available as dns names1.1.1it is now possible to run multiple instances in single dns zone#2(dvenza)added option to override default instance name for use in txt records1.1.0possible breaking change: changeddnspython3package to justdnspythonas Py3 is now supported1.0.4host names are now allowed to have dots in them1.0.3added testsadded proper domain names coversionadded a way to keep track of hosts when adding & removing containers1.0.2fixed error when handling disconnection event without earlier connect oneadded app exception logging