Docker containers can't resolve host on Ubuntu

I have installed Ubuntu server with the latest patches, and I switched to AT+T, and I suddenly was unable to resolve external sites from inside of a Docker container.

How to resolve this?

I noticed that AT+T switched to using ipv6 by default when I did a simple ping:

 $ ping debian.org

PING debian.org(mirror-csail.debian.org (2603:400a:ffff:bb8::801f:3e)) 56 data bytes

This is pretty cool, but my Docker containers are now broken regarding networking.


Solution 1:

I found that the ipv6 hunch seemed to be correct. By turning on ipv6 for Docker, I was able to get networking inside of Docker containers again.

https://medium.com/@skleeschulte/how-to-enable-ipv6-for-docker-containers-on-ubuntu-18-04-c68394a219a2

First modify /etc/docker/daemon.json:

{ 
        "ipv6": true,
        "fixed-cidr-v6": "fd00::/80"
}

Next set up routing:

ip6tables -t nat -A POSTROUTING -s fd00::/80 ! -o docker0 -j MASQUERADE

Note, you need to persist this as it will not survive reboot:

Iptables reload/restart on Ubuntu 18.04

Next restart docker:

 $ systemctl restart docker

Now your Docker containers should have ipv6 again.