自从我更新到Docker版本1.10后,我无法在用户定义的网络上找到其他容器。我无法ping通连接到同一网络的新创建的容器。
我创建了一个名为" my_net"的网络。然后我创建一个带有标志的容器:" - net = my_net"并称之为:" first_container"。然后,当我为网络模式启动另一个具有相同标志的容器时,启动ping到" first_container"我收到错误消息:"错误消息"。但是,如果我ping了我可以从网络上读取的IP地址,我可以ping通。
按照以下顺序,您可以看到我正在做的事情。
[my_user@my_machine ] $ docker network create --driver bridge my_net
8df716599f5160cf049014711c746a225c637a9dea7cb1a788ec7463c3273e4e
[my_user@my_machine ] $ docker network ls
NETWORK ID NAME DRIVER
4b868a0b1e5c none null
0cfa087db0fc host host
8df716599f51 my_net bridge
b7665552cf83 bridge bridge
[my_user@my_machine ] $ docker run -d --name first_container --net=my_net busybox top
750547995a2e515f51d93392d08f4e61d1841be452ad4e4139b5ba13148eee29
[my_user@my_machine ] $ docker network inspect my_net
[
{
"Name": "my_net",
"Id": "8df716599f5160cf049014711c746a225c637a9dea7cb1a788ec7463c3273e4e",
"Scope": "local",
"Driver": "bridge",
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1/16"
}
]
},
"Containers": {
"750547995a2e515f51d93392d08f4e61d1841be452ad4e4139b5ba13148eee29": {
"Name": "first_container",
"EndpointID": "a7fb91ac1b934370699a3f916b6f56c0f81d262a6c2610e9f9ec86cded199bef",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
}
},
"Options": {}
}
]
[my_user@my_machine ] $ docker run --rm --net=my_net busybox 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
172.18.0.3 c2da8f1556e8
[my_user@my_machine ] $ docker run --rm --net=my_net busybox ping -c1 first_container
ping: bad address 'first_container'
[my_user@my_machine ] $ docker run --rm --net=my_net busybox ping -c1 172.18.0.2
PING 172.18.0.2 (172.18.0.2): 56 data bytes
64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.181 ms
--- 172.18.0.2 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.181/0.181/0.181 ms
[my_user@my_machine ] $
任何人都可以帮助我吗?
答案 0 :(得分:0)
您是否可以检查重新启动Docker服务是否解决了问题sudo service docker restart
?另外,在执行first_container
命令时,是否可以检查ping
是否正在运行?我已经能够按照您的步骤成功执行ping操作。我已使用Docker version 1.10.0, build 590d5108
和Docker version 1.10.1, build 9e83765
对其进行了测试。