Docker Network Management-Four network modes
* Host mode (Network of containers, residing on host. The container is the same as the host network. )
Use--net=host to specify when using Docker run
The network that Docker uses is actually the same as a host, and the IP card that is seen in the container is the IP on the host. Equivalent to a host-hosted network. It has some limitations, such as the container opened 80 port, host also opened 80 port, will create a conflict.
For example: Docker run-it--rm--net=host CentOS bash #退出容器, automatically removes containers.
* Container mode (multiple containers, shared IP for a specified container)
Using--net=container:container_id CentOS Bash
Multiple containers Use the specified container's network, see all the container IP is the same container:container_id the first is a fixed format, the second is the ID of the specified container, so that when the new container is started, the new IP and ID are the same as the IP and ID of the specified ID container.
* None mode
Use--net=none to specify
In this mode, no network is configured
* Bridge mode
Use--net=bridge to specify
Default mode, this network mode is not specified by default. This mode assigns a separate network Namespace to each container. A NAT network mode similar to VMware. All containers on the same host will be able to communicate with each other under the same network segment.
2.2 Docker four types of network modes