docker stop XXXX
docker container prune

Create a folder to work in.

mkdir /home/student/docker_networks_lab
cd /home/student/docker_networks_lab

In this lab, we’ll look at how to use Docker to simulate private networks. At this point in the year, you should be able to perform subnet math to determine the size and scope of network groups.

We’ll start by examining a standard Docker container.

docker run -d --name My_Apache ubuntu/apache2

Let’s exec into this container and pull a bash shell

docker exec -it My_Apache /bin/bash

image.png

Try to view the ip address with ifconfig

ifconfig

image.png

Lucky for us, this is an Ubuntu-based image, so we can use the apt package manager within the container.

apt update
apt install net-tools
ifconfig

image.png

Exit the container shell

exit

image.png