Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of two-way connection of docker Network

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

View docker network

docker network ls

[root@master ~]# docker network lsNETWORK ID NAME DRIVER SCOPEe9ecd3b9be87 bridge bridge local45336895a3a4 host host local6a44e8330adb none null local

creating a bridge

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

Add two containers to this bridge

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

Containers can communicate with each other by container name

[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

The above is all the relevant knowledge points introduced in this introduction. Thank you for your study. If there is anything you need to add, you can contact Xiaobian.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report