<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/dockerlabs/dockerlab106_hu457d200db6db3c798b220c9fd9f320f7_1023959_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/dockerlabs\/dockerlab106_hu457d200db6db3c798b220c9fd9f320f7_1023959_600x400_fit_q100_box_3.png'" />
In case you prefer a video, check below our YouTube video for this lab
Create docker hub account. Docker Hub skip this step if you already have one
<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/dockerlogin_hu1f221f14fe461ff4690c69ff8c84d3c3_315570_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/dockerlogin_hu1f221f14fe461ff4690c69ff8c84d3c3_315570_600x400_fit_q100_box_3.png'" />
Open Play with Docker
<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/dockerlabs/pwdlogin_hueec0bc8809651a680023e3a6dcf3c12b_161832_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/dockerlabs\/pwdlogin_hueec0bc8809651a680023e3a6dcf3c12b_161832_600x400_fit_q100_box_3.png'" />
login with your docker hub account.
<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/k8slabs/pwklogindocker_hu053a2a27610a25d64121ac431c222785_112564_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/k8slabs\/pwklogindocker_hu053a2a27610a25d64121ac431c222785_112564_600x400_fit_q100_box_3.png'" />
Click on start
<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/dockerlabs/pwdstart_hu7b3fbdc65158677466b15ae9b9e2a4ca_67286_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/dockerlabs\/pwdstart_hu7b3fbdc65158677466b15ae9b9e2a4ca_67286_600x400_fit_q100_box_3.png'" />
It will start a 4 hr session
<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/k8slabs/pwksession_hu5b589b6b0073ab182d99a0ab899ae088_109284_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/k8slabs\/pwksession_hu5b589b6b0073ab182d99a0ab899ae088_109284_600x400_fit_q100_box_3.png'" />
click on + ADD NEW INSTANCE
<img
title="image"
loading="lazy"
decoding="async"
class="img-fluid img-center"
width="600"
height="400"
src="/images/practice/k8slabs/pwkaddnode_hu5b589b6b0073ab182d99a0ab899ae088_102350_600x400_fit_q100_h2_box_3.webp"
alt="image"
onerror="this.onerror='null';this.src='\/images\/practice\/k8slabs\/pwkaddnode_hu5b589b6b0073ab182d99a0ab899ae088_102350_600x400_fit_q100_box_3.png'" />
<img
title="comment]: ![screenshot"
loading="lazy"
decoding="async"
src=""
alt="comment]: ![screenshot"
class="img-fluid img-center"
width="600"
height="400" />
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
Select the node and click on DELETE
Repeat same for any other open nodes
click close session