I have a docker container that is currently running but Im unable to ping it from my hosts.
PREMs-MacBook-Pro:test_pki_certs prem$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a814241b497c certs_installed/vnet "/bin/bash" 2 hours ago Up 2 hours 0.0.0.0:22->22/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp vnet-work
PREMs-MacBook-Pro:test_pki_certs prem$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' vnet-work
172.17.0.2
PREMs-MacBook-Pro:test_pki_certs prem$ ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Docker containers by default on a bridge network created on the docker host. With docker for Mac, that network will be inside of a VM and routing from your Mac will not be updated to go to the VM. To connect to the container, use your published ports. This also applies to containers running on Linux where you want to access them from another host, since the routing tables of the other hosts won't know how to connect to that private ip.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.