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) 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

Untitled

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

Untitled

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

Exit the Docker image.

exit