Skip to content

Instantly share code, notes, and snippets.

@obrodinho
Forked from fjmk/README.md
Last active Apr 17, 2016
Embed
What would you like to do?
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/rguimaraens/6b9e57673170dff76ad4/raw/c2e799aca9593fe735d11845606dc9753ff86db7/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