Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to analyze Docker cross-host network

Shulou Source: shulou.com Published: 2022-06-01 00:51:16 09月25日 Update

This article will explain in detail how to analyze Docker cross-host network, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

You have learned several Docker network schemes: none, host, bridge, and joined containers, which solve the problem of container communication within a single Docker Host.

Cross-host network solutions include:

Docker native overlay and macvlan.

Third-party solutions: commonly used include flannel, weave, and calico.

Docker network is a very active technical field, and new solutions are constantly being developed, so there is a very important question to ask:

How are so many solutions integrated with docker?

The answer is: libnetwork and CNM.

Libnetwork & CNM

Libnetwork is a docker container network library, and the core content is its defined Container Network Model (CNM). This model abstracts the container network and is composed of the following three types of components:

Sandbox

Sandbox is the network stack of the container and contains the container's interface, routing table, and DNS settings. Linux Network Namespace is the standard implementation of Sandbox. Sandbox can contain Endpoint from different Network.

Endpoint

The purpose of Endpoint is to connect Sandbox to Network. A typical implementation of Endpoint is veth pair, which we will give an example later. An Endpoint can only belong to one network, and can only belong to one Sandbox.

Network

Network contains a set of Endpoint, and Endpoint of the same Network can communicate directly. The implementation of Network can be Linux Bridge, VLAN, and so on.

The following is an example of CNM:

As shown in the figure, there are two containers, one container and one Sandbox, each Sandbox has an Endpoint connected to Network 1, and the second Sandbox has an Endpoint to connect it to Network 2.

Libnetwork CNM defines the network model of docker container, and the driver developed according to this model can work with docker daemon to realize the container network. The native driver of docker includes none, bridge, overlay and macvlan, and the third-party driver includes flannel, weave, calico and so on.

Let's take docker bridge driver as an example to discuss how libnetwork CNM is implemented.

This is a container environment that we discussed earlier:

Two Network: the default network "bridge" and the custom network "my_net2". The implementation is Linux Bridge: "docker0" and "br-5d863e9f78b6".

Three Enpoint, implemented by veth pair, with one end (vethxxx) hanging on the Linux Bridge and the other end (eth0) hanging in the container.

Three Sandbox, implemented by Network Namespace, each container has its own Sanbox.

On how to analyze Docker cross-host network to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Network container scheme content host model analysis one end three two articles more knowledge third parties articles questions development access communication different Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple OPPO Reno Docker macOS Huawei