I just installed docker on CentOS 8. Everything went fine, I’ve run the hello_world test container and the result was successful. The issue is that inside the containers I cannot resolve any DNS queries. For example when I type ping 8.8.8.8 (on any kind of base container such as ubuntu os centOS) i get the correct answer but when I try running ping google.com I don’t get any answer, meaning that the container is unable to resolve the DNS for any URL.
I’ve also tried running a base container like this:
docker run busybox ping -c 1 192.203.230.10ang I’m getting this (correct) output:
[server@localhost ~]$ docker run busybox ping -c 1 192.203.230.10
PING 192.203.230.10 (192.203.230.10): 56 data bytes
64 bytes from 192.203.230.10: seq=0 ttl=51 time=32.413 ms
--- 192.203.230.10 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 32.413/32.413/32.413 msBut now trying resolving the domain google.com with the command:
docker run busybox nslookup google.comI get this output:
[server@localhost ~]$ docker run busybox nslookup google.com
nslookup: write to '8.8.8.8': No route to host
nslookup: write to '8.8.4.4': No route to host
;; connection timed out; no servers could be reachedI’m finding this problem really frustrating since I’ve not found a way to solve it. I'm attaching for completeness a cat /etc/resolv.conf of both the machine running docker and the container itself
On the machine with CentOS 8:
[server@localhost ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4Inside any docker container:
bash-4.4# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4Which looks like a normal and working configuration, but when i try to ping google.com (inside the containers) I get:
bash-4.4# ping google.com
ping: google.com: Try againTell me which command to run to get any info you’d find useful to help me solve this issue, I’ll post it here asap.
11 Answer
The solution to the problem seems to be adding docker as a trusted interface on firewalld using the command:
firewall-cmd --permanent --zone=trusted --add-interface=docker0and then reloading firewalld with:
firewall-cmd --reloadAfter it should work correctly (remember to reboot)
1