Ubuntu 18 and Docker DNS

So I’ve reinstalled linux on my laptop and am running Ubuntu 18.04.1 LTS - Kali was OK, but there was a lot of cruft and one of the more “desktop” distributions seemed more inviting. No, not Arch.

I ran into an issue today however, with DNS resolution failing in my docker containers because of how systemd messes with /etc/resolv.conf. It sets a address, which is systemd-resolved, screwing with docker’s init scripts.

For most people that’s not a problem, but when you regularly connect to networks that block google’s and (which docker reverts to, ugh). That’s a bit of a problem.

The fix, based on this comment in a docker/libnetwork bug is to symlink resolv.conf to the new place for systemd’s file:

sudo mv /etc/resolv.conf{,.bak}
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

This seems to have resolved it for me, and is reported as a fix by others. It’s a bit of a hack, and I’m not sure what other issues it’ll cause, but it seems to work so far :)

Update: 2019-03-21 the ln -s command was backwards - updated thanks to a helpful reader!

#docker #linux #ubuntu #DNS