RedHat4/Docker on Centos 7. Can't reach internet from Docker Instance

789 Views Asked by At

From within my Docker instance (running Red Hat 4), I'm not able to reach the internet. Pinging Google:

 ping google.com
  ]ping: unknown host google.com

I am able to ping the endpoint on my host (Centos 7). Both container and host have the same DNS. Also on my Centos 7 host, I have Selinux disabled along with Firewalld.

1

There are 1 best solutions below

0
On

If you inspect the container that is running you should be able to locate the resolv.conf file. Make sure the file is setup with a nameserver. For example:

docker ps

docker inspect 4fe7454659eb|grep -i resolv "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/4fe7454659eb203f94772f5da1f0c53dc45b2b8e9c71049e039621430cbd0775/resolv.conf",

Once you have the path connect to the running docker container

docker exec -it 4fe7454659eb bash

Then look into the listed directory from above.

cd /mnt/sda1/var/lib/docker/containers/4fe7454659eb203f94772f5da1f0c53dc45b2b8e9c71049e039621430cbd0775/

The resolv.conf file should contain a nameserver. If not, then add one. You will have to save the state of the image after you change the resolv.conf file by committing it. Mine has this:

cat resolv.conf nameserver 10.0.2.3