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

How to automatically execute SQL statements when MySQL in Docker starts

When creating a MySQL container with Docker, some...

Details on how to write react in a vue project

We can create jsx/tsx files directly The project ...

Full analysis of web page elements

Relative Length Units em Description: Relative len...

JavaScript implements asynchronous acquisition of form data

This article example shares the specific code for...

An in-depth summary of MySQL time setting considerations

Does time really exist? Some people believe that ...

Tutorial on installing MYSQL5.7 from OEL7.6 source code

First, download the installation package from the...

JS achieves five-star praise case

This article shares the specific code of JS to ac...

Floating menu, can achieve up and down scrolling effect

The code can be further streamlined, but due to t...

How to use DQL commands to query data in MySQL

In this article, the blogger will take you to lea...

mysql create database, add users, user authorization practical method

1. Create a MySQL database 1. Create database syn...

Steps to solve the MySQL 8.0 time zone problem

Software Version Windows: Windows 10 MySQL: mysql...

Mini Program Custom TabBar Component Encapsulation

This article example shares the specific code for...

Detailed explanation of the use of router-view components in Vue

When developing a Vue project, you often need to ...