{"id":178040,"date":"2020-05-08T09:10:04","date_gmt":"2020-05-08T01:10:04","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=178040"},"modified":"2020-04-24T10:30:12","modified_gmt":"2020-04-24T02:30:12","slug":"network-bidirectional-connection","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/network-bidirectional-connection.html","title":{"rendered":"Docker\u7f51\u7edc\u53cc\u5411\u8fde\u63a5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u672c\u7bc7\u6587\u7ae0\u91cc\u5c0f\u7f16\u7ed9\u5927\u5bb6\u5206\u4eab\u7684\u662f\u4e00\u7bc7\u5173\u4e8edocker\u7f51\u7edc\u53cc\u5411\u8fde\u63a5\u77e5\u8bc6\u70b9\u8be6\u89e3\u5185\u5bb9\uff0c\u6709\u5174\u8da3\u670b\u53cb\u4eec\u53ef\u4ee5\u53c2\u8003\u5b66\u4e60\u4e0b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u67e5\u770bdocker\u7f51\u7edc<\/strong><\/div>\n
\r\ndocker network ls\r\n\r\n[root@master ~]# docker network ls\r\nNETWORK ID     NAME        DRIVER       SCOPE\r\ne9ecd3b9be87    bridge       bridge       local\r\n45336895a3a4    host        host        local\r\n6a44e8330adb    none        null        local\r\n<\/pre>\n
\u521b\u5efa\u7f51\u6865<\/strong><\/div>\n
\r\ndocker network create bridge my-bridge\r\n\r\n[root@master ~]# docker network create -d bridge my-bridge\r\n0ae59991f86c3276acfc5a78dd316f47c124f093e60ce719046f1045ccccb1bd\r\n[root@master ~]# docker network ls\r\nNETWORK ID     NAME        DRIVER       SCOPE\r\ne9ecd3b9be87    bridge       bridge       local\r\n45336895a3a4    host        host        local\r\n0ae59991f86c    my-bridge      bridge       local\r\n6a44e8330adb    none        null        local\r\n<\/pre>\n
\u5c06\u4e24\u4e2a\u5bb9\u5668\u52a0\u5165\u6b64\u7f51\u6865<\/strong><\/div>\n
\r\ndocker network connect my-bridge centos-test-1\r\ndocker network connect my-bridge centos-test-2\r\n\r\n[root@master ~]# docker network connect my-bridge centos-test-1\r\n[root@master ~]# docker network connect my-bridge centos-test-2\r\n<\/pre>\n
\u5bb9\u5668\u5185\u53ef\u76f8\u4e92\u901a\u8fc7\u5bb9\u5668\u540d\u8fdb\u884c\u901a\u4fe1<\/strong><\/div>\n
\r\n[root@master ~]# docker exec -it centos-test-1 bash\r\n[root@bd4aa8b35c8d \/]# ping centos-test-2\r\nPING centos-test-2 (172.18.0.3) 56(84) bytes of data.\r\n64 bytes from centos-test-2.my-bridge (172.18.0.3): icmp_seq=1 ttl=64 time=0.131 ms\r\n64 bytes from centos-test-2.my-bridge (172.18.0.3): icmp_seq=2 ttl=64 time=0.163 ms\r\n^C\r\n--- centos-test-2 ping statistics ---\r\n2 packets transmitted, 2 received, 0% packet loss, time 999ms\r\nrtt min\/avg\/max\/mdev = 0.131\/0.147\/0.163\/0.016 ms\r\n\r\n[root@master ~]# docker exec -it centos-test-2 bash\r\n[root@d8eac6105db2 \/]# ping centos-test-1\r\nPING centos-test-1 (172.18.0.2) 56(84) bytes of data.\r\n64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=1 ttl=64 time=0.187 ms\r\n64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=2 ttl=64 time=0.405 ms\r\n64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=3 ttl=64 time=0.150 ms\r\n^C\r\n--- centos-test-1 ping statistics ---\r\n3 packets transmitted, 3 received, 0% packet loss, time 4ms\r\nrtt min\/avg\/max\/mdev = 0.150\/0.247\/0.405\/0.113 ms\r\n[root@master ~]# docker exec -it centos-test-2 bash\r\n[root@d8eac6105db2 \/]# ping centos-test-1\r\nPING centos-test-1 (172.18.0.2) 56(84) bytes of data.\r\n64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=1 ttl=64 time=0.187 ms\r\n64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=2 ttl=64 time=0.405 ms\r\n64 bytes from centos-test-1.my-bridge (172.18.0.2): icmp_seq=3 ttl=64 time=0.150 ms\r\n^C\r\n--- centos-test-1 ping statistics ---\r\n3 packets transmitted, 3 received, 0% packet loss, time 4ms\r\nrtt min\/avg\/max\/mdev = 0.150\/0.247\/0.405\/0.113 ms\r\n<\/pre>\n

\u4ee5\u4e0a\u5c31\u662f\u672c\u6b21\u4ecb\u7ecd\u7684\u5168\u90e8\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u611f\u8c22\u5927\u5bb6\u7684\u5b66\u4e60\u5982\u679c\u6709\u4efb\u4f55\u9700\u8981\u8865\u5145\u7684\u53ef\u4ee5\u8054\u7cfb\u5c0f\u7f16\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

docker network ls [root@master ~]# docker network ls NE […]<\/p>\n","protected":false},"author":63,"featured_media":178041,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-178040","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/178040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=178040"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/178040\/revisions"}],"predecessor-version":[{"id":178102,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/178040\/revisions\/178102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/178041"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=178040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=178040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=178040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}