In the wave of cloud computing and microservices, Docker, as a lightweight containerization technology, has become a key tool for the development and deployment of applications. Docker ensures rapid and consistent deployment of applications by providing isolated environments. Networking is a core component of the containerized environment, responsible for the communication between containers as well as the connection between containers and the outside world. This article will delve into the four types of Docker networks: host, bridge, none, and container, to help developers and system administrators better understand and utilize Docker networking.

The Four Docker Network Types

  1. Host Mode: Sharing the Host’s Network
    Host mode is a special configuration of Docker container networking, enabled by using the --net=host option in the docker run command. When a container runs in host mode, it does not obtain a separate Network Namespace but shares the host’s network environment. This means the container directly uses the host’s IP address and network ports.For example, if a web application container that listens on port 80 is launched on a host with an IP address of, it can be accessed directly via without the need for NAT translation. This mode has advantages in network performance because it avoids the overhead of network address translation, but it may also pose security risks since the container can directly access the host’s network resources.
  2. Bridge Mode: The Default Docker Network
    Bridge mode is the default Docker container network configuration, specified by the --net=bridge option. In this mode, each container is assigned to a separate Network Namespace and connected to a virtual bridge, typically docker0.When Docker starts, it creates this virtual bridge on the host and assigns it a private IP address. Containers then obtain IP addresses from this private address space. Bridge mode supports communication between containers and can communicate with the outside world through specific Iptable rules.
  3. None Mode: No Networking
    None mode is enabled with the --net=none option, where the container has its own Network Namespace but Docker does not configure any network interfaces for it. Containers in this mode are completely isolated with no network access points.This mode is suitable for containers that do not need to communicate with the outside world and only perform internal tasks. For example, some security-sensitive applications may choose none mode to ensure the highest level of network isolation.
  4. Container Mode: Sharing Network with Other Containers
    With the --net=container:NAME_or_ID option, a new container can be set to share the same Network Namespace with an existing container. This means the two containers will share the same network configuration, including IP addresses and port numbers.Container mode is suitable for a group of closely cooperating containers that need to communicate with each other in a manner similar to multiple processes on the same host. In this mode, the network communication efficiency between containers is extremely high.