- 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:
$ 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 following (for example):
$ docker network inspect frontend | grep subnet
You should receive something...