Docker中网络双向连接知识点有哪些
短信预约 -IT技能 免费直播动态提醒
这篇文章主要为大家展示了“Docker中网络双向连接知识点有哪些”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Docker中网络双向连接知识点有哪些”这篇文章吧。
查看docker网络
docker network ls[root@master ~]# docker network lsNETWORK ID NAME DRIVER SCOPEe9ecd3b9be87 bridge bridge local45336895a3a4 host host local6a44e8330adb none null local
创建网桥
docker network create bridge my-bridge[root@master ~]# docker network create -d bridge my-bridge0ae59991f86c3276acfc5a78dd316f47c124f093e60ce719046f1045ccccb1bd[root@master ~]# docker network lsNETWORK ID NAME DRIVER SCOPEe9ecd3b9be87 bridge bridge local45336895a3a4 host host local0ae59991f86c my-bridge bridge local6a44e8330adb none null local
将两个容器加入此网桥
docker network connect my-bridge centos-test-1docker network connect my-bridge centos-test-2[root@master ~]# docker network connect my-bridge centos-test-1[root@master ~]# docker network connect my-bridge centos-test-2
容器内可相互通过容器名进行通信
[root@master ~]# docker exec -it centos-test-1 bash[root@bd4aa8b35c8d /]# ping centos-test-2PING centos-test-2 (172.18.0.3) 56(84) bytes of data.64 bytes from centos-test-2.my-bridge (172.18.0.3): icmp_seq=1 ttl=64 time=0.131 ms64 bytes from centos-test-2.my-bridge (172.18.0.3): icmp_seq=2 ttl=64 time=0.163 ms^C--- centos-test-2 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 999msrtt min/avg/max/mdev = 0.131/0.147/0.163/0.016 ms[root@master ~]# docker exec -it centos-test-2 bash[root@d8eac6105db2 /]# ping centos-test-1PING centos-test-1 (172.18.0.2) 56(84) bytes of data.64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=1 ttl=64 time=0.187 ms64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=2 ttl=64 time=0.405 ms64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=3 ttl=64 time=0.150 ms^C--- centos-test-1 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 4msrtt min/avg/max/mdev = 0.150/0.247/0.405/0.113 ms[root@master ~]# docker exec -it centos-test-2 bash[root@d8eac6105db2 /]# ping centos-test-1PING centos-test-1 (172.18.0.2) 56(84) bytes of data.64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=1 ttl=64 time=0.187 ms64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=2 ttl=64 time=0.405 ms64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=3 ttl=64 time=0.150 ms^C--- centos-test-1 ping statistics ---3 packets transmitted, 3 received, 0% packet loss, time 4msrtt min/avg/max/mdev = 0.150/0.247/0.405/0.113 ms
以上是“Docker中网络双向连接知识点有哪些”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341