Let’s start this lab with some cleanup first. Stop all your running containers.
docker ps

docker stop container_name
docker rm container_name
###Alternatively, this will delete ALL container
docker container prune
If you need to delete any images that you feel you don’t need, now would be a good time to delete any images as well. (We’ll need the ubuntu/apache2 image and the rastasheep/ubuntu-sshd images for this lab)
docker images
#Comment: List images
docker image rm <image_name>
#Delete anything you don't need
In the previous lab, we created an html file showing a picture within a docker container running an Apache2 web server. This is an example of 1-Tier architecture. The data (information in /var/www/html/) is on the same node as the running Apache2 process. This specific example (hosting web content on Apache2) can be problematic for the following reasons:
- If the Apache2 server gets compromised or we need to upgrade it, the data in
/var/www/html is also in the same container. If we *docker rm <apache2_container_name>*the data will also be deleted. (Not ideal.)
- We want to put ourselves in a position where we can delete, update, or roll back the Apache2 webserver without impacting the data in
/var/www/html/
In the last lab, we learned to map external ports to internal docker ports for networking. This time, we’ll learn to:
- Map volumes (folders) from other locations to our docker container.
- Start our Docker container so the folder
/var/www/html within the container maps to a folder on the host (Kali) machine, not the Docker container itself.
On the host VM (Kali), let’s create a folder to map as a volume
mkdir webpages
Then, let’s create an index.html inside of this webpages folder
cd webpages
pico index.html

Verify the full path to your webpages folder
pwd
