Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Cross-Host Container Communication based on macvlan in Docker

2025-04-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What the editor wants to share with you this time is how Docker can communicate across host containers based on macvlan. The article is rich in content. Interested friends can learn about it. I hope you can get something after reading this article.

Find two test machines:

[root@docker1 centos_zabbix] # docker network lsNETWORK ID NAME DRIVER SCOPE19ac9a55bedb bridge bridge local0a3cbfe2473f host host localaab77f02a0b1 none null local [root@docker1 centos_zabbix] # docker network create-- driver macvlan-- subnet 10.0.0.0 parent=ens33 macvlan_1 24-- gateway 10.0.254-o execute both commands It means to add the network type of macvlan [root@docker1 centos_zabbix] # docker network lsNETWORK ID NAME DRIVER SCOPE19ac9a55bedb bridge bridge local0a3cbfe2473f host host local4e5ccdc657e1 macvlan_1 macvlan localaab77f02a0b1 none null local

Make the centos6.9:v2 version of the image available on both servers:

Execute on one: [root@docker1 centos_zabbix] # docker run-it-- network macvlan_1-- ip=10.0.0.155 centos6.9:v2 / bin/bash: [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.155PING 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 ms64 bytes from 10.0.0.155: icmp_seq=2 ttl=64 time=0.569 ms here you can ping another container to show that the containers are the same ^ C

This kind of problem is

The ip address cannot be repeated. If there are duplicates, there will be confusion. For example, if both ip are 155s, then the ping155 network can be connected by ping, but the ssh does not know which one it is connected to. In fact, if it is not connected, the link will make an error, so the overlay network is introduced to manage IP.

After reading this article on how Docker can communicate across host containers based on macvlan, if you think the article is well written, you can share it with more people.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report