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

A brief introduction to the Network Mode of Docker

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

When creating a docker container, there are four network modes to choose from

Bridge mode (default mode)

Host mode

Container mode

None mode

Bridge mode is the default network mode of docker. If you don't write the-net parameter, it is bridge mode.

When the Docker process starts, a virtual bridge named docker0 is created on the host, and the Docker container launched on this host is connected to the virtual bridge.

The ip of the docker0 bridge is 172.17.0.1 IP 24. The bridge assigns a separate IP to each container (at 172.17.0.0) and sets the IP address of the docker0 as the default gateway for the container.

Create a pair of virtual network card veth pair devices on the host, and Docker will place one end of the veth pair device in the newly created container and name it eth0 (the container's network card), and the other end in the docker0 bridge, named after a similar name such as vethxxx.

That is, in bridge mode, each container has a separate network and namespace.

Brctl show

The Container mode specifies that a newly created container and an existing container share a Network Namespace and network information, while others, such as file systems, process lists, and so on, are isolated.

In other words, the two containers share an IP (eth0) information, where the two containers are equivalent to one container in the bridge mode, and the processes of the two containers can communicate through the lo Nic device.

As with bridge mode, the network and namespaces of containers and hosts are still isolated.

In Host mode, the container and host share the Nic information and namespace, and the container does not have a separate IP. However, other aspects of the container, such as file systems, process lists, and so on, are isolated from the host.

Using none mode, the Docker container has its own Network Namespace, but there is no network configuration for the Docker container. In other words, the Docker container does not have network card, IP, routing and other information. We need to add network cards, configure IP and so on for the Docker container.

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