#Host1与Host2中的容器需要通信,需要把两边的网络打通,即将宿主机网卡添加到虚拟网桥中 [root@localhost ~]# ovs-vsctl add-port ovs0 ens192 [root@localhost ~]# ovs-vsctl show
4. 验证[root@localhost ~]# docker exec -it test1 ping 192.168.1.12 [root@localhost ~]# docker exec -it test1 ping 192.168.1.13 [root@localhost ~]# docker exec -it test1 ping 192.168.1.14 [root@localhost ~]# docker exec -it test2 ping 192.168.1.13 [root@localhost ~]# docker exec -it test2 ping 192.168.1.14
预期:
test1 ping test2: fail
test1 ping test3: success
test1 ping test4: fail
test2 ping test3: fail
test2 ping test4: success
根据验证结果显示,结果符合预期,请见截图: