0

I'm disabled to ping by name (ping google.com) from my docker container, but only by ip (ping 8.8.8.8). From cmd I can ping by name and ip, so I think is some network setup on my docker.

I'm not too much in networking, so if anybody knows how to allow pinging by name, I would be more than grateful.

Regards, Stefan

1 Answers1

0

First, some web server such as google.com don't reply to ping commands. If you are able to see that the IP was resolved, then you don't have any problems.

Otherwise, you can check which dns server the container is using by running the command:

docker exec -it <container-name> cat /etc/resolve.conf

If that doesn't show 8.8.8.8 as a configured dns server, you need to do one of the following:

Configure the systemd dns for docker, by creating the file /etc/systemd/system/docker.service.d/dns.conf with the following content:

[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon -H fd:// --dns 8.8.8.8 --dns x.x.x.x --dns x.x.x.x

Alternatively, specify a dns list when starting the container by adding the --dns option to run

docker run --dns 8.8.8.8 ...
yamenk
  • 46,736
  • 10
  • 93
  • 87