Skip to content

Instantly share code, notes, and snippets.

@obrodinho
Last active December 30, 2016 09:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obrodinho/44bab7ec7a343a09d7c78b07a17ecb4c to your computer and use it in GitHub Desktop.
Save obrodinho/44bab7ec7a343a09d7c78b07a17ecb4c to your computer and use it in GitHub Desktop.
dnsdock working on systemd for a dummy guy like me :|

Hey.

If you didin't get the instructions on the git repo of DnsDock, let's take a step back.

Follow these steps to install DNSDock on your Ubuntu machine:

1. Set BIP (bridge ip) for docker0 interface.

It's better to set an address, cause docker can change addresses between versions. We need to edit /lib/systemd/system/docker.service

Use the editor of your choice. I like vim: sudo vim /lib/systemd/system/docker.service

Add these two options after "... -H fd://" on the ExecStart directive. The options are: --bip=172.17.42.1/24 --dns=172.17.42.1

In addition to BIP, we are telling docker to use the same address as DNS: Any discovery will pass through this address.

Restart daemons: sudo systemctl daemon-reload

Restart docker: sudo systemctl restart docker

2. Optional: Make discovery available to the host machine

This step is optional. I like to access containers via their addresses, like: service1.bleh.dev, xxx.service.docker, db.enterprise.rgs...

To make it work, edit /etc/resolvconf/resolvconf.d/head. So edit that file and add: nameserver 172.17.42.1. Note that is the same address as DNS option set on step #1

Update resolvconf: sudo resolvconf -u

3. Now you can start a dnsdock container

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

Relate to the git repo to have more options. Note that I'm using --rm instead of -d to force container removal after I stop them. It's useful when testing the various options of DnsDock.

Notes

I found that docker0 default address, on Ubuntu 16.04 and docker 1.11, is 172.18.0.1. I made it work with that address first.

To know what is the adress of docker0 run route. A list of network addresses will come up. docker0 -> 172.18.0.0

Using ifconfig you can get more info on the docker0 interface, like the connection ip address. Simply the first available ip on the network: 172.18.0.1

Some docker versions ago, the default bridge address was different. Was something like: 172.17.42.1

route:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.25.1    0.0.0.0         UG    600    0        0 wlp3s0
link-local      *               255.255.0.0     U     1000   0        0 docker0
172.18.0.0      *               255.255.0.0     U     0      0        0 docker0
192.168.25.0    *               255.255.255.0   U     600    0        0 wlp3s0

ifconfig:

docker0   Link encap:Ethernet  HWaddr 02:42:95:09:db:39  
          inet addr:172.18.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:95ff:fe09:db39/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:76 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:6057 (6.0 KB)  TX bytes:4248 (4.2 KB)

Going further.

After making it work (we pay the price of our stupidity), I've found some good sources to take another step:


Thanks Tõnis Tiigi for the awesome work!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment