Docker DNS is not working. But possible to ping ip. In Fedora 32

Viewed 552

In my Fedora 32 machine DNS is working better. DNS lookup is working when ping google.com.

PING google.com (172.217.160.174) 56(84) bytes of data.
64 bytes from bom05s12-in-f14.1e100.net (172.217.160.174): icmp_seq=1 ttl=117 time=41.5 ms
64 bytes from bom05s12-in-f14.1e100.net (172.217.160.174): icmp_seq=2 ttl=117 time=47.2 ms

I build following simple docker image using default bridge network. (I need bridge network. My issue is working when i using host network. And DockerImage will have more commands)

FROM tailor/docker-libvips:node-10.9
docker build --tag dinuka/video-file-service-test-sandbox:node-10.9 .
docker run -dit --name video-test-1 dinuka/video-file-service-test-sandbox:node-10.9

I have logged to the container using following command.

docker attach video-test-1

After that i have tried to ping an IP. It is success.

/# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=42.5 ms

But it is not working to domain

/# ping google.com
ping: google.com: Temporary failure in name resolution

The container DNS is correct. It is same as my machine name server.

/# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.1.1

My machine OS is Fedora 32. I have disable selinux and firewalld. I have tried many solutions in stackoverflow. But any can't solve this.

1 Answers

You need to manually add masquerading to the network interface:

ZONE=$(sudo firewall-cmd --get-zone-of-interface=<internet facing interface>)
sudo firewall-cmd --zone=$ZONE --add-masquerade --permanent success 
sudo firewall-cmd --reload success
sudo systemctl restart docker
Related