Get the App
SLTechnology News&Howtos  ›  Servers  › 

The Network Mode of Docker

Shulou Source: shulou.com Published: 2022-06-02 17:38:06 09月22日 Update

Docker's network model

Docker's network models can be roughly divided into five types. After Docker is installed, the host will create three networks by default, namely bridge network, host network and none network. You can use docker network ls command to view them.

1. None Network

In this network mode, the container only has lo loopback network and no other network cards. None Network can be specified at container creation time with--network=none. This type of network has no way to connect to the network, and a closed network can ensure the security of the container very well.

2. Host network

Specify by the command--network=host that the container using host mode can communicate with the outside world directly using the IP address of docker host, and the service port inside the container can also use the port of the host without NAT. The biggest advantage of host is that the network performance is relatively good, but the port already used on docker host cannot be used anymore, and the isolation of the network is not good.

3. bridge network

The default network mode of the container, docker will create a Linux bridge named docker0 when installed, in the case of not specifying--network, the container created will be hung on docker0 by default.

Start any container and view the newly generated NIC information

After creating a container, a new network interface is mounted on docker0, which is the virtual network card created when the container was created. The bridge pattern creates a separate network stack for containers, ensuring that processes within containers use separate network environments, enabling network isolation between containers and between containers and docker hosts.

4. Container mode

When creating a container, use--network=container:NAME_or_ID. This mode specifies that the container's network shares a Network Namespace with an existing container when creating a new container, but does not configure any network for the docker container. This docker container has no network card, IP, routing, etc., so you need to manually add network cards and configure IP for the docker container.

5.User-defined mode

There are three main network drivers available for user-defined mode: bridge, overlay, macvlan. Bridge drivers are used to create networks similar to the bridge mentioned earlier;overlay and macvlan drivers are used to create networks, IP, etc. across hosts.

Tags: Network container mode network card port driver between create information command host host namely type guarantee independence configuration isolation maximum security Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple macOS NVidia OPPO Reno MySQL