[Cloud native] The difference between Docker cross-host network Overlay and Macvlan

 

Cross-host network communication solution

  1. docker native overlay and macvlan

  2. Third-party flannel, weave, calico

1.overlay network

In Docker, the Overlay network is a container network driver that allows creating a virtual network on multiple Docker hosts so that containers can communicate with each other through this network.

The Overlay network uses VXLAN (Virtual Extensible LAN) technology to realize communication between multiple hosts. Containers on each Docker host can join the Overlay network, and they can communicate as if they were on the same host, without knowing the network configuration of the underlying host.

When a container sends a network request, the Overlay network driver encapsulates the request into a VXLAN packet and sends it to the host where the target container is located through the physical network of the underlying host. The Overlay network driver on the target host decapsulates the VXLAN packet and passes the request to the target container.

Overlay network has the following characteristics:

  1. Cross-host communication: Containers can run on different Docker hosts and communicate through the Overlay network.

  2. Automatic routing: The Overlay network driver automatically handles routing between containers, enabling containers to communicate directly by container name.

  3. Security: The Overlay network uses encryption and authentication to protect communication between containers and ensure data security.

  4. Scalability: The Overlay network can create thousands of containers on multiple hosts, and can automatically handle the dynamic addition and removal of containers.

  5. Flexibility: Overlay network can be used together with other network drivers (such as Bridge, Host, etc.) to meet different network requirements.

The Overlay network is one of the commonly used network drivers in Docker. It provides the ability to communicate across hosts, making it easy for containers to communicate over the network in a distributed environment.

2.macvlan network

Macvlan is a new attempt, a true turning point in network virtualization technology. The Linux implementation is very lightweight as they are simply associated with a Linux Ethernet interface or subinterface for separation between networks and connection to the physical network compared to traditional Linux Bridge isolation. Macvlan offers many unique features and there is plenty of room for further innovation with various modes. Two high-level advantages of these methods are the positive performance of bypassing Linux bridges and the simplicity of having few moving parts. Removing the bridge that traditionally resides between the Docker host NIC and the container interface leaves a very simple setup, including the container interface, directly connected to the Docker host interface. Since there is no port mapping in these cases, external services can be easily accessed.

In Docker, Macvlan networking is a container networking driver that allows containers to be directly connected to a physical network so that containers can have their own MAC and IP addresses, just like a physical host.

The Macvlan network driver creates a virtual network interface that is bound to the physical network interface and connects the container to the physical network via bridge mode. Each container can be assigned an independent MAC address and IP address, which allows the container to communicate directly with other physical devices without port mapping or network address translation.

Macvlan network has the following characteristics:

  1. Connect directly to the physical network: Containers can communicate directly with other devices on the physical network without NAT or port mapping.

  2. Independent MAC address and IP address: Each container can have its own independent MAC address and IP address, completely isolated from the physical host and other containers.

  3. High performance: The Macvlan network driver connects the container to the physical network through the bridge mode, providing a network transmission speed close to the performance of the physical network.

  4. Flexibility: Macvlan network can be used together with other network drivers, such as Bridge, Overlay, etc., to meet different network requirements.

  5. Applicable to specific scenarios: Macvlan networks are applicable to scenarios that require direct communication between containers and physical networks, such as containers running as part of a physical host, network device virtualization, and so on.

It should be noted that the Macvlan network requires some network configuration on the host, including creating virtual network interfaces, configuring subnets and gateways, and so on. Therefore, certain network knowledge and permissions are required when using the Macvlan network.

In general, Macvlan networking is a container network driver directly connected to the physical network, which provides high performance and flexibility, and is suitable for scenarios that require containers to communicate directly with the physical network.

Guess you like

Origin blog.csdn.net/weixin_53678904/article/details/131699230