docker container cant connect to internet on vm

  centos7, connection, docker, virtual-machine

On one of my three servers (centos7) docker containers show a weird behaviour. After downloading the image the docker container is not able to download packages from the internet.
The only difference between the server with the errors and the other ones is that the server with errors is setup as a vm while the other ones are dedicated.

I first tried to run the docker compose tutorial ( but while creating the service the container couldnt fetch the website to download the package.

RUN apk add --no-cache gcc musl-dev linux-headers
 ---> Running in c2bbe974f34b

At this step the process got stuck and i cancelled the process.
To test the network connectivity i used busyboxes next.
First i pinged google on each server, which worked on all three.

sudo docker run --rm -i  busybox ping

PING ( 56 data bytes
64 bytes from seq=0 ttl=115 time=7.437 ms
64 bytes from seq=1 ttl=115 time=7.275 ms
64 bytes from seq=2 ttl=115 time=7.315 ms

An nslookup on the other hand didnt work on the server with the connection issues. On the other servers it worked as expected.

sudo docker run --rm -i  busybox nslookup


Non-authoritative answer:

*** Can't find No answer

I already read on other posts that i should check differences in the /etc/resolv.conf file on container and host, which is not the case. Another suggestion was reseting the docker networks to initialize them again, which had the same results. I checked the Docker logs but couldnt find anything that looks like an error or warning.
It cant be a firewallD problem cause i deactivated the firewall.
If i run containers with –network host everything works as expected…

Does anyone have suggestions what i can do next to understand this issue? I would really really appreciate it 🙂

Source: Docker Questions