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 does the docker container communicate with the host

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the knowledge of "how the docker container communicates with the host". In the actual case operation, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

How does the docker container communicate with the host? When the docker service starts, the host machine exists as a gateway in the same network segment as other Docker containers, just like the relationship between the router and each connecting terminal, and the host is similar to the router.

1. Bridge mode

When the docker process starts, a virtual bridge named docker0 will be created on the host, and an interface eth0,eth0 and docker0 will be created inside the container that can only be seen inside the container. It works like a physical layer 2 switch and can communicate with each other.

Communication between docker host containers and different host containers, command execution process:

# docker run-tid-net=bridge-name docker_bri1 ubuntu-base:v3#docker run-tid-net=bridge-- name docker_bri2 ubuntu-base:v3#brctl show#docker exec-ti docker_bri1 / bin/bash#docker exec-ti docker_bri1 / bin/bash#ifconfig-a#route-n

2. Host mode

If the container starts in host mode, the container will not have a separate Network NameSpace like the first one. Instead, share a Network NameSpace with the host. Use the ip and port of the host, but the container's system, process list, etc., are still isolated from the host.

Communication between docker homestay containers and different host containers, command execution:

# docker run-tid-net=host-name docker_host1 ubuntu-base:v3#docker run-tid-net=host-- name docker_host2 ubuntu-base:v3#docker exec-ti docker_host1 / bin/bash#docker exec-ti docker_host1 / bin/bash#ifconfig-a#route-n

3. None mode

The Docker container has its own Network Namespace, but there is no network configuration for the Docker container.

Communication between docker homestay containers and different host containers

# docker run-tid-- net=none-- name docker_non1 ubuntu-base:v3#docker exec-ti docker_non1 / bin/bash#ifconfig-a#route-n this is the end of "how the docker container communicates with the host". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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