Junior
What is a network containerization module in Docker?
sobes.tech AI
Answer from AI
The Container Network Module (CNM) is a Docker specification that defines the interaction model between containers and the external world. It consists of three main primitives:
- Sandbox: The container's network stack, including its interfaces, routing tables, and DNS.
- Endpoint: The connection point of the Sandbox to the Network.
- Network: A network segment to which Endpoints can connect. Containers within the same Network can communicate with each other.
CNM provides a plugin interface that allows various drivers to implement network functions. Docker Engine manages Sandboxes and Endpoints, while network drivers are responsible for creating and configuring Networks.
Examples of built-in Docker network drivers:
- bridge: Creates a NAT network for containers to communicate with each other and the outside world through the host IP.
- host: The container uses the host's network stack directly.
- none: The container has no network interface.
- overlay: Creates a distributed network across multiple Docker hosts for swarm services.
Example of creating a bridge network:
docker network create my_bridge_network
Connecting a container to this network:
docker run -d --network my_bridge_network nginx