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

Implementation of overlay for Docker Communication across Host Container

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

Share

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

This article mainly explains the implementation of Docker cross-host container communication overlay, the content is clear, interested partners can learn, I believe it will be helpful after reading.

There are also two servers:

Preparatory work:

Set the hostname of the container

Consul:kv type storage database (key:value) docker01, 02: vim / etc/docker/daemon.json {"hosts": ["tcp://0.0.0.0:2376", "unix:///var/run/docker.sock"]. This line has been changed to modify your own docker configuration file "cluster-store": "consul://10.0.0.11:8500". "cluster-advertise": "10.0.0.11 usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd 2376" another can write its own ip} vim / etc/docker/daemon.jsonvim / usr/lib/systemd/system/docker.serviceExecStart=/usr/bin/dockerd-- change the line containerd=/run/containerd/containerd.sock to look like this Both of them have to change their systemctl daemon-reloadsystemctl restart docker.

On docker01:

Docker run-d-p 8500 server 8500-h consul-- name consul progrium/consul-server-bootstrap this command makes [root@docker1 centos_zabbix] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE10.0.0.11:5000/kode v2 6914fda5fd44 4 hours ago 502MBkode v2 6914fda5fd44 4 hours ago 502MB10.0 after setting the hostname of the container .0.11: 5000/centos6.9_nginx_ssh v3 92b1087df3f5 13 hours ago 431MBcentos6.9_nginx_ssh v3 92b1087df3f5 13 hours ago 431MBcentos6.9_nginx_ssh v2 6307e23ee16d 13 hours ago 431MB b94c822488f9 13 hours ago 431MBcentos6.9_nginx_ssh v1 f01eeebf918a 13 hours ago 431MB 54167f1d659b 13 hours ago 431MB 71474e616504 13 hours ago 430MBcentos6.9_ssh v2 03387f99f022 14 hours ago 307MB 82d0e9ce844b 14 hours ago 195MBkode v1 c0f486ac58fe 15 hours ago 536MBprogrium/consul latest 09ea64205e55 4 years ago 69.4MB there is [root@docker1 centos_zabbix] # Docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1016753ee64d progrium/consul "/ bin/start-server..." 4 minutes ago Exited (255) 3 minutes ago 53/tcp, 53/udp, 8300-8302/tcp, 8400/tcp, 8301-8302/udp, 0.0.0.0 53/udp 8500-> 8500/tcp consul

Finally, visit the page:

2) create an overlay network

Docker network create-d overlay-- subnet 172.16.1.0 ol1 24-- gateway 172.16.1.254 this network segment cannot be the same as the host machine, and you can execute this command on any one.

Check the network of the container to see if there is an overlay

[root@docker1 shell] # docker network lsNETWORK ID NAME DRIVER SCOPEe480a4fe5f4b bridge bridge local0a3cbfe2473f host host local4e5ccdc657e1 macvlan_1 macvlan localaab77f02a0b1 none null local8ae111afded7 ol1 overlay global

3) start container test

One: docker run-it-- network ol1-- name test01 centos6.9_ssh:v2 / bin/bash another: docker run-it-- network ol1-- name test02 centos6.9_ssh:v2 / bin/bash can be connected with test02 through test01.

After that, you can connect with test02 through test01.

True principle:

Each container has two network cards. Eth0 realizes the communication between containers, and eth2 implements container access to the public network.

After reading the above content, do you have a further understanding of the implementation of Docker cross-host container communication overlay? if you want to learn more, you are welcome to follow the industry information channel.

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