image

Create docker hub account. Docker Hub skip this step if you already have one

image

Open Play with Docker

image

login with your docker hub account.

image

Click on start

image

It will start a 4 hr session

image

click on + ADD NEW INSTANCE

image

List all docker networks

Solution
docker network ls

create a new bridge network

Solution
docker network create -d bridge mbn

Run a container web with image nginx and new network, expose port 8080 as 80

Solution
docker run -d -p 8080:80 --name web --network=mbn nginx

Inspect network settings of container created in previous step

Solution
docker inspect web
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web

Run a container jumphost with image alpine and connect to it

Solution
docker run -it --name jumphost alpine

Access port 80 of container web from jumphost

Solution
wget -T 3 172.19.0.2

Change network used by container jumphost to mbn

Solution
docker network connect mbn jumphost

Start container jumphost

Solution
docker start jumphost

Connect to jumhost container and access port 80 of container web

Solution
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

Inspect docker network mbn

Solution
docker inspect mbn

check network mbn

you will observe that both containers are connected to it

Disconnect container web and jumphost from network mbn

Solution
docker network disconnect mbn jumphost
docker network disconnect mbn web

List all docker networks

Solution
docker network ls

Check docker info

Solution
docker info
docker info | grep -i network

Check option for docker network command

Solution
docker network

Delete all three nodes and close session

  1. click on first node and then DELETE
  2. Repeat same for second and third node
  3. click close session

image

Congratulations you have completed this lab

Let us know if you still have any question
Youtube video for this lab