For this lab, you’ll need the VM utilized in Lab_01
In the last lab, we started a container using the docker run command. You’ll rarely use docker run without specifying at least a few other parameters. Most of the time, we’ll be passing in run-time parameters.
We are going to spin up a new container from our ubuntu/apache2 container, only this time, we are going to pass in two parameters:
- We’ll specify a name that we can use to reference it
- We’ll use
-d so that it runs as a daemon in the background, and we’ll get our terminal session back.
Let’s run it this time like this:
docker run -d --name My_Apache ubuntu/apache2
docker ps

That -d parameter gave us the shell right back. Now, we have a docker image with a name (My_Apache) we can easily reference.
At this point, we have a Docker container running on the VM. To access the container command line and make changes to it, we’ll need shell access.
Access the docker container shell:
docker exec -it My_Apache /bin/bash

Please take note of the command above. Any time you want to access a command line within a Docker container, you’ll need to do it like that.
Let’s change this image by just adding a file.
ls
echo "This is a line of text" > MyNewFile.txt
ls

In the next few steps, we’ll examine how these changes can be either saved permanently or destroyed completely.
Exit the Docker image.
exit