Docker containers unable to connect to internet Docker containers unable to connect to internet docker docker

Docker containers unable to connect to internet


I was able to solve the issue. It turns out in the digitalocean firewall for the droplet, the outbound traffic were blocked for UDP. Only TCP traffic was allowed. And hence the dns resolution was not working.

DNS uses TCP for Zone transfer and UDP for name queries either regular (primary) or reverse. UDP can be used to exchange small information whereas TCP must be used to exchange information larger than 512 bytes.DNS requires port 53 for name resolution and from the docker logs it can be seen port 53 is being used but since udp outbound traffic were blocked, dns was not working.

However, I did try to force docker to use TCP by setting dns_opt=use-vc setting. This didn't work. UDP traffic was allowed and now it is working.


It could be simply that your host iptables rule is blocking.
On your host machine, double check the output of iptables -L -v -n. Or temporarily even try something like iptables -P INPUT ACCEPT and then after confirming it work, revert it with iptables -P INPUT DROP. For the access to the outside world instead of local docker dns, replace INPUT with FORWARD.