Recently I had to run dns in docker container over multiple hosts, the notorious docker multihost environment. Docker multihost setup is generally difficult, hopefully it get's resolved soon with ongoing development. One way of doing this is with skydock and skydns.
More info on skydock and skydns can be found at git hub:
Start skydns on one of the hosts, for example host1:
docker run -d --name skydns \ -p 53:53/udp \ -p 8080:8080/tcp \ crosbymichael/skydns:latest \ -nameserver="220.127.116.11:53" \ -domain="deki.local" If running on Centos 7 use IP with port bind: docker run -d --name skydns \ -p $HOSTIP:53:53/udp \ -p $HOSTIP:8080:8080/tcp \ crosbymichael/skydns:latest \ -nameserver="18.104.22.168:53" \ -domain="deki.local"
$HOSTIP is the IP address of host1.
Skydock will run on both hosts , host1 and host2. On run this on both hosts:
docker run -d -v /var/run/docker.sock:/docker.sock \ --name skydock crosbymichael/skydock \ -ttl 30 -environment dev -s /docker.sock \ -domain "deki.local" \ -skydns="http://$DNS_IP:8080/"
In this case since we run skydns on host1,
$DNS_IP is IP address of host1. In this setup we have one DNS on host1, and skydock running on both. Each time container is started/stopped/destroyed skydock on that node will update DNS records for us. This setup can be further improved by running multiple DNS servers and multiple instances of skydock for higher availability.