In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain the example analysis of Docker network for you in detail. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Docker networks
Namespace-based network Network isolation A sample # create two network namespaceip netns add ns1ip netns add ns2# to create a pair of network card devices sudo ip link add veth-a type veth peer name veth-b# put the network card in two namespace sudo ip link set veth-a netns ns1sudo ip link set veth-b netns ns2# enable two network cards sudo ip netns exec ns1ip link set dev veth-a upsudo ip netns exec ns2 ip link set dev veth-b up# to two Ip address information assigned to the network card sudo ip netns exec ns1 ip addr add 10.0.0.1 bootstrap 24 dev veth-asudo ip netns exec ns2 ip addr add 10.0.0.2 advertise=172.17.0.200# nohup consul agent 24 dev veth-b# validate network connectivity execute ping veth-bsudo ip netns exec ns1 ping 10.0.0.2overlay networkconsuldocker run-d-p 8500 dev veth-b# 8500 in ns1-restart=always-- name=consul progrium/consul-server-bootstrap-advertise=172.17.0.200# nohup consul agent-server-bootstrap-ui- Data-dir / var/lib/consul-client=10.0.0.2-bind=10.0.0.2 & > / var/log/consul.log & other nodes docker.service configuresystemctl status docker.service # to see where the docker.service is ExecStart=/usr/bin/dockerd-H fd://-- cluster-store=consul://172.17.0.200:8500-- cluster-advertise=ens33:2376 # ExecStart=/usr/bin/dockerd-H fd://-H tcp://0 .0.0.0: 2375-- cluster-store consul://10.0.0.2:8500-- cluster-advertise 10.0.0.2 ExecStart=/usr/bin/dockerd ExecStart=/usr/bin/dockerd-H fd://-H tcp://0.0.0.0:2375-- cluster-store consul://10.0.0.2:8500-- cluster-advertise 10.0.0.3 cluster-store consul://10.0.0.2:8500 2375 check whether the service is found in consul
Url: http://172.17.0.200:8500/ui/#/dc1/kv/docker/nodes/
Create overlay network docker network create-d overlay ov1root@node1:~# docker network lsNETWORK ID NAME DRIVER SCOPEba720f1ef854 bridge bridge local5b69a097a085 host host local9c19e28d7789 none null localbaa622c89664 ov1 overlay global * Root@master:~# docker network ls | grep ov1baa622c89664 ov1 overlay global * root@node2:/etc/apt# docker network ls | grep ov1baa622c89664 ov1 overlay global * # check logs [Node2] docker run-itd-- name busybox01-- network=ov1 busyboxdocker inspect-- format=' {{range .NetworkSettings.Networks}} {{.IPAddress}} {{end}} 'f454d47dd873 # # find ip# errordocker Error response from daemon: endpoint with name busybox01 already exists in network ov1.root@node1:~# docker run-itd-- name busybox02-- network ov1 busybox d7f1a2c5d81c33513269ba99306b6f5cb7f64e02ab7583552f8fe71aab719952root@node1:~# docker exec busybox02 ping-c 4 busybox01PING busybox01 (10.0.0.2): 56 data bytes64 bytes from 10.0.0.2: seq=0 ttl=64 time=0.760 ms64 bytes from 10.0.0.2: seq=1 ttl=64 time=0.521 mscheck netnsln-s / var/run/docker/netns / var/run/netnsip netns list restart
If docker host is shut down and there is no previously created overlay network after restart, it is time to check whether the consul/ (KBV) service on docker host has been stopped.
Macvlan opens the promiscuous mode of the network card root@node2:~# ip link show ens332: ens33: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:27:f1:72 brd ff:ff:ff:ff:ff:ffip link set ens33 promisc onroot@node2:~# ip link show ens332: ens33: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:27:f1:72 brd ff:ff:ff:ff : ff:ffvmware/virtualbox also needs to open the promiscuous mode create macvlanroot@node1:~# docker network create-d macvlan-- subnet=172.16.0.0/24-- gateway=172.16.0.1-o parent=ens33 macnet01 # to run the same command root@node1:~# docker network ls on node2 | grep macnet010f2f883adb06 macnet01 macvlan localdocker run-itd-- name busybox04-- ip 172.16.0.3-- network macnet01 busyboxroot@node1:~# docker Exec busybox04 ping-c 4 172.17.0.4root@node2:~# docker exec busybox05 ping-c 4 172.17.0.3docker network namespace open source management tool
Netenter
Pipework Network docker Container Network configuration tool
Pipework
Docker Advanced Network practice linux network namespace (under the command line)
Create a network namespace
Show network namespace
Delete network namespace
Execute the shell command in network namespace
This is the end of this article on "sample Analysis of Docker Networks". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.