Docker overlay realizes container intercommunication across hosts

Docker overlay realizes container intercommunication across hosts

Environmental Description

IP Registration Center
192.168.20.5 Consule
192.168.20.6
192.168.20.7

1. Docker configuration

All physical machines need to be configured. Just change the corresponding network card name eno3 and consul address

sudo vim /lib/systemd/system/docker.service
#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --cluster-store=consul://192.168.20.5:8500 --cluster-advertise=eno3:2376 --insecure-registry=0.0.0.0/0

Note that this configuration file has a higher priority /etc/systemd/system/docker.service

Check startup

sudo systemctl daemon-reload 
sudo systemctl restart docker.service 
ps -ef | grep dockerd

insert image description here

2. Create a registry and network

Create a network segment and network name on consul

docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp -h consul progrium/consul-server -bootstrap -ui-dir /ui
# Create a subnet, and the network will be automatically synchronized to other machines docker network create -d overlay --subnet=192.168.21.0/24 overlay-net

Check

docker ps
docker network ls

insert image description here

View the physical machines connected to the registry

insert image description here

3. Start the container

Container names cannot be repeated

# On 192.168.20.5
docker run -d -it --name test1 --net=overlay-net centos bash
# On 192.168.20.6
docker run -d -it --name test2 --net=overlay-net centos bash
# On 192.168.20.7
docker run -d -it --name test3 --net=overlay-net centos bash

It can be seen that they can ping each other

insert image description here

This is the end of this article about docker overlay to achieve cross-host container interoperability. For more relevant docker container interoperability content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Cross-host communication between docker containers-overlay-based implementation method
  • Detailed explanation of Docker cross-host container communication overlay implementation process
  • Docker cleaning killer/Docker overlay file takes up too much disk space
  • Implementation of Docker cross-host network (overlay)
  • How to build a Docker overlay network

<<:  Several ways to solve the problem of floating causing the height of the parent element to collapse in CSS

>>:  JavaScript basics for loop and array

Recommend

Summary of methods to prevent users from submitting forms repeatedly

Duplicate form submission is the most common and ...

Example of how to install kong gateway in docker

1. Create a Docker network docker network create ...

SQL to implement time series dislocation restoration case

Table of contents 1. Requirements description 2. ...

A brief discussion on mysql backup and restore for a single table

A. Installation of MySQL backup tool xtrabackup 1...

js to realize a simple disc clock

This article shares the specific code of js to im...

Deeply understand how nginx achieves high performance and scalability

The overall architecture of NGINX is characterize...

Solution to the problem that elements with negative z-index cannot be clicked

I was working on a pop-up ad recently. Since the d...

How to delete extra kernels in Ubuntu

Step 1: View the current kernel rew $ uname -a Li...

Using front-end HTML+CSS+JS to develop a simple TODOLIST function (notepad)

Table of contents 1. Brief Introduction 2. Run sc...

Detailed tutorial on how to monitor Nginx/Tomcat/MySQL using Zabbix

Table of contents Zabbix monitors Nginx Zabbix mo...

Configure Mysql master-slave service implementation example

Configure Mysql master-slave service implementati...

PHP-HTMLhtml important knowledge points notes (must read)

1. Use frameset, frame and iframe to realize mult...