At this point, you should know how to:
- Use
*docker pull* to download a docker image from Dockerhub.
- Use
*docker run* to start a fresh container from a docker image
- Parameters so far:
-d (background) and --name (name the container)
- Use
*docker stop* and *docker start* to power off and power on containers.
- Use
*docker commit* to save changes from a container to a new image.
- Use
*docker ps* to list running containers
- Use
*docker images* to list available images on disk
- Use
*docker rm* to delete an individual container
Just like we can use *docker rm* to delete containers we don’t want anymore, we can use *docker image rm* to delete an image from disk.
docker images
docker image rm <image_name>
#This will delete an image from disk
In the last two labs, we downloaded an Apache2 docker image running a web server. This web server is in the default configuration, so it listens on port 80. Let’s spin it up and test whether we can reach the default webpage.
docker run -d --name temp_container ubuntu/apache2

Now, from your host machine (Windows), we’ll go to the IP address of the VM on which the docker image is running. First, identify the IP Address of the Kali machine running our docker containers.
- Be sure your Kali Linux VM has its networking card in bridged mode.

Go to the IP address of the Docker Host (look above) on your Windows machine.

Here’s the problem. The Docker image is listening on the interface docker0 (pictured above). This interface is only directly accessible from the docker container host (Kali).
Whenever we create a docker image and want to expose a port on the container to the outside world, we’ll have to use the *-p* flag. We can only do this when we first run the container. This means we must delete the current container and create a new one. (Easy!)