Answers
Here are example answers for the questions of this chapter:
- The three core elements of the Docker CNM are as follows:
- Sandbox: A network namespace for a container where its network stack resides
- Endpoint: An interface that connects a container to a network
- Network: A collection of endpoints that can communicate with each other directly
- To create a custom Docker
bridge
network calledfrontend
, you can use thedocker network create
command with the--driver
flag set tobridge
(which is the default driver) and the--subnet
flag to specify the subnet for the network. Here’s an example command:$ docker network create --driver bridge \ --subnet 172.25.0.0/16 frontend
This will create a bridge network named frontend
with a subnet of 172.25.0.0/16
. You can then use this network when starting containers with the --
network
option:
$ docker run --network frontend <docker-image>
- To run two
nginx:alpine
containers attached to...