Here are some sample answers to the questions presented in this chapter:
- The three core elements are sandbox, endpoint, and network.
- Execute this command:
$ docker network create --driver bridge frontend
- Â Run this command:
$ docker container run -d --name n1 \
--network frontend -p 8080:80 nginx:alpine
$ docker container run -d --name n2 \
--network frontend -p 8081:80 nginx:alpine
Test that both NGINX instances are up and running:
$ curl -4 localhost:8080
$ curl -4 localhost:8081
You should be seeing the welcome page of NGINX in both cases.
- To get the IPs of all attached containers, run this command:
$ docker network inspect frontend | grep IPv4Address
You should see something similar to the following:
"IPv4Address": "172.18.0.2/16",
"IPv4Address": "172.18.0.3/16",
To get the subnet used by the network, use the...