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

Solve nginx "504 Gateway Time-out" error

Students who make websites often find that some n...

Automatically install the Linux system based on cobbler

1. Install components yum install epel-rpm-macros...

How to monitor mysql using zabbix

Zabbix deployment documentation After zabbix is ​...

How to use provide to implement state management in Vue3

Table of contents Preface How to implement Vuex f...

Detailed explanation of Docker data backup and recovery process

The data backup operation is very easy. Execute t...

Zabbix monitors the process of Linux system services

Zabbix automatically discovers rules to monitor s...

WeChat applet implements search box function

This article example shares the specific code for...

Detailed explanation of the role of key in React

Table of contents Question: When the button is cl...

Building command line applications with JavaScript

Table of contents 1. Install node 2. Install Comm...

MySQL table name case selection

Table of contents 1. Parameters that determine ca...

Kali Linux Vmware virtual machine installation (illustration and text)

Preparation: 1. Install VMware workstation softwa...

CSS inheritance method

Given a div with the following background image: ...