Docker implements cross-host container communication based on macvlan

Docker implements cross-host container communication based on macvlan

Find two test machines:

[root@docker1 centos_zabbix]# docker network ls
NETWORK ID NAME DRIVER SCOPE
19ac9a55bedb bridge bridge local
0a3cbfe2473f host host local
aab77f02a0b1 none null local
 
[root@docker1 centos_zabbix]# docker network create --driver macvlan --subnet 10.0.0.0/24 --gateway 10.0.0.254 -o parent=ens33 macvlan_1
This command executes both, which means adding the macvlan network type [root@docker1 centos_zabbix]# docker network ls
NETWORK ID NAME DRIVER SCOPE
19ac9a55bedb bridge bridge local
0a3cbfe2473f host host local
4e5ccdc657e1 macvlan_1 macvlan local
aab77f02a0b1 none null local

Make sure both servers have the centos6.9:v2 version image:

Execute on one machine:
[root@docker1 centos_zabbix]# docker run -it --network macvlan_1 --ip=10.0.0.155 centos6.9:v2 /bin/bash
Execute on one machine:
[root@docker2 opt]# docker run -it --network macvlan_1 --ip=10.0.0.156 centos6.9_ssh:v2 /bin/bash
[root@9ea3f69d89c4 /]# ping 10.0.0.155
PING 10.0.0.155 (10.0.0.155) 56(84) bytes of data.
64 bytes from 10.0.0.155: icmp_seq=1 ttl=64 time=2.15 ms
64 bytes from 10.0.0.155: icmp_seq=2 ttl=64 time=0.569 ms The fact that another container can be pinged here indicates that the containers are identical^C

This kind of problem is

IP addresses cannot be repeated. If they are repeated, confusion will occur. For example, if two IP addresses are both 155, then ping155 can be pinged, but ssh will not know which machine it is connected to. In fact, it cannot connect and the link will be wrong. Therefore, the overlay network is introduced to manage IP addresses.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Cross-host communication between docker containers-overlay-based implementation method
  • Implementation of Docker container connection and communication
  • Detailed explanation of Docker container cross-host multi-network segment communication solution
  • Detailed explanation of Docker cross-host container communication overlay implementation process
  • Detailed explanation of direct routing in cross-host communication of Docker containers
  • Operations of communication between Docker containers and external network communication

<<:  WeChat applet to save albums and pictures to albums

>>:  Brief analysis of centos 7 mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar

Recommend

What does input type mean and how to limit input

Common methods for limiting input 1. To cancel the...

Docker installation steps for Redmine

Download the image (optional step, if omitted, it...

How to install the latest version of docker using deepin apt command

Step 1: Add Ubuntu source Switch to root su root ...

4 ways to implement routing transition effects in Vue

Vue router transitions are a quick and easy way t...

Learn the key knowledge that must be mastered in the Vue framework

1. What is Vue Vue is a progressive framework for...

What we have to say about CSS absolute and relative

Written in the opening: Absolute said: "Rela...

Detailed explanation of formatting numbers in MySQL

Recently, due to work needs, I need to format num...

Summary of clipboard.js usage

Table of contents (1) Introduction: (2) The ways ...

A simple explanation of MySQL parallel replication

1. Background of Parallel Replication First of al...

How to use the WeChat Mini Program lottery component

It is provided in the form of WeChat components. ...

Use of MySQL DDL statements

Preface The language classification of SQL mainly...

Analyze the problem of pulling down the Oracle 11g image configuration in Docker

1. Pull the image docker pull registry.cn-hangzho...

Solve the problem of managing containers with Docker Compose

In Docker's design, a container runs only one...