首页 > 解决方案 > 无法 ping docker 主机,但世界是可达的

问题描述

我能够从运行 docker 容器的容器中 ping 世界其他地方,但不能 ping 主机。我确定有人以前遇到过这个问题

请参阅下面的详细信息

Ubuntu 14.04.2 LTS (GNU/Linux 3.16.0-30-generic x86_64
**Container is using "bridge" network
Docker version 18.06.1-ce, build e68fc7a**

IP address for eth0:    135.25.87.162
IP address for eth1:    192.168.122.55
IP address for eth2:    135.21.171.209
IP address for docker0: 172.17.42.1

route

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         135.21.248.1    0.0.0.0         UG    0      0        0 eth1
135.21.171.192  *               255.255.255.192 U     0      0        0 eth2
135.21.248.0    *               255.255.255.0   U     0      0        0 eth1
135.25.87.128   *               255.255.255.192 U     0      0        0 eth0
172.17.0.0      *               255.255.0.0     U     0      0        0 docker0
192.168.122.0   *               255.255.255.192 U     0      0        0 eth1


#ping commands from container

# ping google.com
PING google.com (64.233.177.113): 56 data bytes
64 bytes from 64.233.177.113: icmp_seq=0 ttl=29 time=51.827 ms
64 bytes from 64.233.177.113: icmp_seq=1 ttl=29 time=50.184 ms
64 bytes from 64.233.177.113: icmp_seq=2 ttl=29 time=50.991 ms
^C--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 50.184/51.001/51.827/0.671 ms

# ping 135.25.87.162
PING 135.25.87.162 (135.25.87.162): 56 data bytes
^C--- 135.25.87.162 ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss
root@9ed17e4c2ee3:/opt/app/tomcat#

标签: dockerdocker-networking

解决方案


推荐阅读