What are the communication modes of docker?

青灯夜游
Release: 2022-02-21 16:06:48
Original
3996 people have browsed it

Docker’s communication modes are: 1. Bridge network mode, also known as brigde bridge. When the network is not specified, communication between containers is carried out through the bridge bridge; 2. host Host mode; 3. container network mode; 4. none network mode.

What are the communication modes of docker?

The operating environment of this tutorial: linux5.9.8 system, docker-1.13.1 version, Dell G3 computer.

Four communication modes of docker containers

1. Bridge network mode

First, By default, when docker runs a container, the host will create a bridge, which is a virtual bridge named docker 0. The default docker 0 ip is 172.17.0.1. The bridge then assigns a virtual subnet ip to the container and uses the network The bridge ip acts as a gateway. Without specifying a network, communication between containers is carried out through the bridge network. Then the bridge communicates with the host image for IP conversion, port mapping, etc.

In fact, students who have experience in network communication should be able to easily understand the principle of this communication by looking at the picture below. , somewhat similar to Layer 3 routing and switching.

What are the communication modes of docker?

#2. Host host mode

If the container specifies the network mode as host, the container will not have its own network namespace. Instead, it shares a network and IP with the host. The container will not virtualize its own network card, IP, etc. Of course, except for network communication, which is bound to the host, the rest of the container content is safely isolated from the host. This is very inconvenient when doing container migration and is not recommended. The principle diagram is as follows,

What are the communication modes of docker?

3. Container network mode:

Analysis: share the network with another running docker container --net=container:containerID

Try not to conflict with the direct port of the container, and adopt the first-come-first-served principle

4, none network mode

Container specifies the network mode - when net is none, the docker container has its own network namespace, but all network configurations must be configured by yourself, such as ip, network card, etc. This method is very troublesome and is not recommended. The principle diagram is as follows

What are the communication modes of docker?

Summary:

Docker communication mode Configuration Description
host mode –net=host The container and the host share the Network namespace.
container mode –net=container:NAME_or_ID The container shares the Network namespace with another container. A pod in kubernetes is a Network namespace shared by multiple containers.
none mode –net=none The container has an independent Network namespace, but no network settings are made for it, such as assigning veth pair and bridge connection, configure IP, etc.
bridge mode –net=bridge (default is this mode)

Recommended learning: "docker video tutorial"

The above is the detailed content of What are the communication modes of docker?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template