得知互动
标题:
Docker overlay 网络搭建的方法
[打印本页]
作者:
云V小编
时间:
2022-4-11 10:46
标题:
Docker overlay 网络搭建的方法
[root@n1 vagrant]# consul agent -server -bootstrap-expect 3 -data-dir /etc/consul.d -node=node1 -bind=172.20.20.10 -ui -client 0.0.0.0[root@n2 vagrant]# consul agent -server -bootstrap-expect 3 -data-dir /etc/consul.d -node=node2 -bind=172.20.20.11 -ui -client 0.0.0.0 -join 172.20.20.10[root@n3 vagrant]# consul agent -server -bootstrap-expect 3 -data-dir /etc/consul.d -node=node3 -bind=172.20.20.12 -ui -client 0.0.0.0 -join 172.20.20.10[root@n1 vagrant]# consul membersNode Address Status Type Build Protocol DC Segmentnode1 172.20.20.10:8301 alive server 1.1.0 2 dc1 <all>node2 172.20.20.11:8301 alive server 1.1.0 2 dc1 <all>node3 172.20.20.12:8301 alive server 1.1.0 2 dc1 <all># /etc/sysconfig/docker-networkDOCKER_NETWORK_OPTIONS=--cluster-store=consul://172.20.20.10:8500 --cluster-advertise=172.20.20.10:2376[root@n1 sysconfig]# docker network lsNETWORK ID NAME DRIVER SCOPE5a8df7650e34 bridge bridge local8e574df4fb90 docker_gwbridge bridge locald69aab5b2621 host host local7301c62bca4d none null local[root@n1 sysconfig]# docker network create -d overlay myoverlay36feac75fb49edcf8920ed39109424b833501268942fb563708aa306fccfb15c[root@n1 sysconfig]# docker network lsNETWORK ID NAME DRIVER SCOPE5a8df7650e34 bridge bridge local8e574df4fb90 docker_gwbridge bridge locald69aab5b2621 host host local36feac75fb49 myoverlay overlay global7301c62bca4d none null local# /etc/sysconfig/docker-networkDOCKER_NETWORK_OPTIONS=--cluster-store=consul://172.20.20.11:8500 --cluster-advertise=172.20.20.11:2376[root@n2 vagrant]# docker network lsNETWORK ID NAME DRIVER SCOPE9f2b7d40a69f bridge bridge local1d9ee9546c81 docker_gwbridge bridge locale1f72fa7710c host host local36feac75fb49 myoverlay overlay global372109bb13bc none null local[root@n3 vagrant]# docker network lsNETWORK ID NAME DRIVER SCOPE14cf16d37c9b bridge bridge localca426545fedb docker_gwbridge bridge localb57d2f555fa2 host host local36feac75fb49 myoverlay overlay globalfcb5da0380e4 none null local[root@n1 sysconfig]# docker run --network myoverlay busybox"Networks": { "myoverlay": { "IPAMConfig": null, "Links": null, "Aliases": [ "e7d558b35607" ], "NetworkID": "36feac75fb49edcf8920ed39109424b833501268942fb563708aa306fccfb15c", "EndpointID": "6b1c975847b506a151940893e3ac189a7053cb34dda4ec2b5797c93f6eeb3534", "Gateway": "", "IPAddress": "10.0.0.2", "IPPrefixLen": 24, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:0a:00:00:02" } }[root@n2 sysconfig]# docker run --network myoverlay busybox"Networks": { "myoverlay": { "IPAMConfig": null, "Links": null, "Aliases": [ "f673ccb5ab32" ], "NetworkID": "36feac75fb49edcf8920ed39109424b833501268942fb563708aa306fccfb15c", "EndpointID": "39f8e9e098ce3faf039aa60e275ec90428f86c6378f5b4c54d8682741e71673f", "Gateway": "", "IPAddress": "10.0.0.3", "IPPrefixLen": 24, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:0a:00:00:03" } }[root@n2 vagrant]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESf673ccb5ab32 busybox "sh" 2 minutes ago Up 2 minutes objective_pare[root@n2 vagrant]# docker exec -ti f673ccb5ab32 /sh/ # ping 10.0.0.2PING 10.0.0.2 (10.0.0.2): 56 data bytes64 bytes from 10.0.0.2: seq=0 ttl=64 time=1.309 ms64 bytes from 10.0.0.2: seq=1 ttl=64 time=0.535 ms64 bytes from 10.0.0.2: seq=2 ttl=64 time=1.061 ms64 bytes from 10.0.0.2: seq=3 ttl=64 time=0.764 ms^C--- 10.0.0.2 ping statistics ---4 packets transmitted, 4 packets received, 0% packet lossround-trip min/avg/max = 0.535/0.917/1.309 msping 是通的, overlay 网络搭建成功!
以上就是本文的全部内容,希望对大家的学习有所帮助。
欢迎光临 得知互动 (https://bbs.dezhifl.com/)
Powered by Discuz! X3.4