Skip to content

Instantly share code, notes, and snippets.

@fjmk
Last active October 5, 2016 13:01
Show Gist options
  • Save fjmk/a2bc6f9e01df9966c17b to your computer and use it in GitHub Desktop.
Save fjmk/a2bc6f9e01df9966c17b to your computer and use it in GitHub Desktop.
Howto use dnsdock in Ubuntu 14.04 trusty

Howto use dnsdock in Ubuntu 14.04 trusty

Using dnsdock resolves the problem of the changing IP's of containers. It is much easier to start a named container and use dns on the host to access the container simply by its name.

patch your /etc/ files so NetworkManager's dnsmasq to use the dnsdock nameserver.

sudo su -
cd
wget https://gist.githubusercontent.com/fjmk/a2bc6f9e01df9966c17b/raw/ad58b0823271e2f448df21f8a2226b719dec9353/etc-dnsdock.patch
cd /etc
patch < /root/etc-dnsdock.patch
resolvconf -u
exit

start dnsdock container (and restart it on boot)

sudo docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name dnsdock -p 172.17.42.1:53:53/udp --restart always  tonistiigi/dnsdock

test your new dns

ping dnsdock
diff --git a/default/docker b/default/docker
index 14e6601..2981969 100644
--- a/default/docker
+++ b/default/docker
@@ -4,6 +4,7 @@
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
+DOCKER_OPTS="--bip=172.17.42.1/24 --dns 172.17.42.1"
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
# If you need Docker to use an HTTP proxy, it can also be specified here.
diff --git a/network/interfaces b/network/interfaces
index f481d04..035973a 100644
--- a/network/interfaces
+++ b/network/interfaces
@@ -6,3 +6,4 @@ iface lo inet loopback
#auto br0
#iface br0 inet dhcp
# bridge_ports eth0
+dns-search docker
diff --git a/resolvconf/resolv.conf.d/head b/resolvconf/resolv.conf.d/head
index 74505dd..8a1f825 100644
--- a/resolvconf/resolv.conf.d/head
+++ b/resolvconf/resolv.conf.d/head
@@ -1,2 +1,3 @@
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
+nameserver 172.17.42.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment