测试NS,以及连通性
docker network inspect overlay-net
"Containers": {
"6d0ec15c4c167835be87c5dbdd4a55652483c6b3a031590803620e1dc717de4a": {
"Name": "web",
"EndpointID": "c664c6478b060f727ad5bcf3e416acc934651eb3d28aea97017dda7a3859ea28",
"MacAddress": "02:42:0a:00:09:02",
"IPv4Address": "10.0.9.2/24",
"IPv6Address": ""
},
"6d2b5306f00b9648d7213aa0c8ec8e17827eac858767c55cda0d7b3f5d57fa64": {
"Name": "web2",
"EndpointID": "49b1c3e206ffec8b03a9617ec658c3c88be92b3042e2d9d8511523b787d6b12c",
"MacAddress": "02:42:0a:00:09:03",
"IPv4Address": "10.0.9.3/24",
"IPv6Address": ""
}
docker exec -it web ping -c 3 web2
PING web2 (10.0.9.3): 56 data bytes
64 bytes from 10.0.9.3: icmp_seq=0 ttl=64 time=0.610 ms
64 bytes from 10.0.9.3: icmp_seq=1 ttl=64 time=0.539 ms
64 bytes from 10.0.9.3: icmp_seq=2 ttl=64 time=0.513 ms
--- web2 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.513/0.554/0.610/0.041 ms
OK, 可以看到我们web容器,已经可以和web2容器通信
今天我们的目的达到,建立 swarm 集群,overlay 网络,容器可以跨主机通信