DNS assignment for docker bridge on systemd-network machines

#!/bin/hi *

I’m running docker here on a Kubuntu 17.04 and encountered that my containers are not able to resolve any IP address properly. This is due to the fact that (K)Ubuntu turned to systemd-network and systemd-resolve which assigns DNS servers per interface.

Effect: when inside a container, I can ping other containers. I can ping the host. But the nameserver is set to 8.8.8.8 which renders me unable to resolve any address.

In short (on host):
$ systemd-resolve --status
Global

Link 5 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no

Link 2 (enp0s31f6)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.0.1
192.168.0.2
DNS Domain: some.domain.local

(changed IP addresses)

This leaves all containers unable to resolve any DNS entry. As a result, any “apt-get update && apt-get install …” will fail.

As a quick fix I did
$ grep Exec /etc/systemd/system/multi-user.target.wants/docker.service
ExecStart=/usr/bin/dockerd --dns 192.168.0.1 -H fd://
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker.service

But this is inferior since DNS entries may change.

What is the best approach to remedy this situation?

Thx