In case you prefer a video, check below our YouTube video for this lab
Open Play with Docker
login with your docker hub account.
Task: List all docker networks
docker network ls
Task: create a new bridge network
docker network create -d bridge mbn
Task: Run a container web with image nginx and new network, expose port 8080 as 80
docker run -d -p 8080:80 --name web --network=mbn nginx
Task: Inspect network settings of container created in previous step
docker inspect web
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web
Task: Run a container jumphost with image alpine and connect to it
docker run -it --name jumphost alpine
Task: Access port 80 of container web from jumphost
wget -T 3 172.19.0.2
Task: Change network used by container jumphost to mbn
docker network connect mbn jumphost
Task: Start container jumphost
docker start jumphost
Task: Connect to jumhost container and access port 80 of container web
docker exec -it jumphost sh
this command will connect to container jumphost shell
wget -T 3 172.19.0.2
try to access container web from jumphost
this time it will download index.html file
cat index.html
it will display nginx welcome page
Task: Inspect docker network mbn
docker inspect mbn
check network mbn
you will observe that both containers are connected to it
Task: Disconnect container web and jumphost from network mbn
docker network disconnect mbn jumphost
docker network disconnect mbn web
Task: List all docker networks
docker network ls
Task: Check docker info
docker info
docker info | grep -i network
Task: Check option for docker network command
docker network
Task: Delete all open nodes/instances and close session