我一直在尝试设置docker环境。 让我感到困扰的一个问题是,我的docker容器无法访问我的主机。
在容器A中:
ping 192.168.39.184 # host ip
没有回应
# traceroute 192.168.39.184
traceroute to 192.168.39.184 (192.168.39.184), 30 hops max, 46 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
容器使用用户定义的网桥:
"Networks": {
"DB_DOCKER_NETWORK": {
"IPAMConfig": {},
"Links": null,
"Aliases": [
"8efacc8c4dbd"
],
"NetworkID": "3af9e7395bbcf0d374772245bac50fb714479ed17abcefc0214bb3dca9ef630c",
"EndpointID": "5aef17340477f0bff4169faeca2c0a5ed8dc10d2a628a2f1c6f0b6503f5dc6f3",
"Gateway": "172.20.0.1",
"IPAddress": "172.20.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:14:00:02",
"DriverOpts": {}
},
并且容器可以ping通另一台主机(192.168.39.216):
# ping 192.168.39.216
PING 192.168.39.216 (192.168.39.216): 56 data bytes
64 bytes from 192.168.39.216: seq=0 ttl=63 time=0.178 ms
64 bytes from 192.168.39.216: seq=1 ttl=63 time=0.229 ms
主机和解析配置为:
# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
cat /etc/resolv.conf
search scloudm
nameserver 127.0.0.11
options ndots:0