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:

Let’s run it this time like this:

docker run -d --name My_Apache ubuntu/apache2
docker ps

Untitled

That -d parameter gave us the shell right back. Now, we have a Docker image with a name (My_Apache) that 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 inside of the container itself, we’ll need shell access.

Access the Docker container shell:

docker exec -it My_Apache /bin/bash

Untitled

Please take note of the command above. Any time you want to access a command line in a Docker container, you’ll have the option to do so with that command.

Let’s change this image by just adding a file.

ls
echo "This is a line of text" > MyNewFile.txt
ls

Untitled

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

Exit the Docker image.

exit