时间:2021-05-02
查看docker网络
docker network ls
? 1 2 3 4 5 [root@master ~]# docker network ls NETWORK ID NAME DRIVER SCOPE e9ecd3b9be87 bridge bridge local 45336895a3a4 host host local 6a44e8330adb none null local创建网桥
docker network create bridge my-bridge
? 1 2 3 4 5 6 7 8 [root@master ~]# docker network create -d bridge my-bridge 0ae59991f86c3276acfc5a78dd316f47c124f093e60ce719046f1045ccccb1bd [root@master ~]# docker network ls NETWORK ID NAME DRIVER SCOPE e9ecd3b9be87 bridge bridge local 45336895a3a4 host host local 0ae59991f86c my-bridge bridge local 6a44e8330adb none null local将两个容器加入此网桥
? 1 2 docker network connect my-bridge centos-test-1 docker network connect my-bridge centos-test-2 ? 1 2 [root@master ~]# docker network connect my-bridge centos-test-1 [root@master ~]# docker network connect my-bridge centos-test-2容器内可相互通过容器名进行通信
? 1 2 3 4 5 6 7 8 9 [root@master ~]# docker exec -it centos-test-1 bash [root@bd4aa8b35c8d /]# ping centos-test-2 PING 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 ms 64 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 999ms rtt min/avg/max/mdev = 0.131/0.147/0.163/0.016 ms ? 1 2 3 4 5 6 7 8 9 10 [root@master ~]# docker exec -it centos-test-2 bash [root@d8eac6105db2 /]# ping centos-test-1 PING 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 ms 64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=2 ttl=64 time=0.405 ms 64 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 4ms rtt min/avg/max/mdev = 0.150/0.247/0.405/0.113 ms以上就是本次介绍的全部相关知识点,感谢大家的学习如果有任何需要补充的可以联系小编。
原文链接:https://www.cnblogs.com/xie123/p/12159152.html
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1、如果docker主机不需要通过代理连接外网则docker的相关命令(如dockersearch)或docker容器与网络相关的操作都可以正常进行,不需要特殊
jenkins构建Docker镜像实例详解前言:jenkins有Docker镜像,而之前我们说过使用jenkins打包Docker镜像,那么可否用jenkins
dockerpythonapi安装配置的详解1.docker宿主机配置文件修改$vim/etc/default/docker#再已有OPTS中添加DOCKER_
RetrievingDataoverHTTPPython内置了sockets可以实现与网络连接并通过Python提取数据的功能。socket是可以提供双向连接的
Android判断是否能真正上网的实例详解检测网络是否连接实现代码:/***检测网络是否连接**@return*/privatebooleanisNetwork