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

Vite2.0 Pitfalls

Table of contents Vite project build optimization...

Vue implements left and right sliding effect example code

Preface The effect problems used in personal actu...

Implementation of two basic images for Docker deployment of Go

1. golang:latest base image mkdir gotest touch ma...

How to add Tomcat Server configuration to Eclipse

1. Window -> preferences to open the eclipse p...

Nginx service 500: Internal Server Error one of the reasons

500 (Internal Server Error) The server encountere...

MySQL Error 1290 (HY000) Solution

I struggled with a problem for a long time and re...

A complete guide on how to query and delete duplicate records in MySQL

Preface This article mainly introduces the method...

MySQL learning notes: data engine

View the engines supported by the current databas...

Vue+spring boot realizes the verification code function

This article example shares the specific code of ...

Use Xshell to connect to the Linux virtual machine on VMware (graphic steps)

Preface: I recently started to study the construc...

A brief discussion on the corresponding versions of node node-sass sass-loader

Table of contents The node version does not corre...

Solve the problem of running hello-world after docker installation

Installed Docker V1.13.1 on centos7.3 using yum B...

MySQL 5.7.17 winx64 installation and configuration method graphic tutorial

Windows installation mysql-5.7.17-winx64.zip meth...

Transplanting the mkfs.vfat command in busybox under Linux system

In order to extend the disk life for storing audi...

Recommend a cool interactive website made by a front-end engineer

Website link: http://strml.net/ By Samuel Reed Ti...