• Exercise 1 -- Download a second base image

a. Search for your preferred Linux distribution (e.g., centos, ubuntu, fedora, ...)

b. Pull it

c. Check its history

  • Exercise 2 -- Check the statistics of a running container

Hint: docker --help

  • Exercise 3 -- Copy files from // to containers

Example: Copy the Apache server logs on the VM. They are typically stored in "/var/log/httpd"

Example 2: Create a text file on the VM and copy it over the container in "/tmp". Then, attach to the container and cat the file

  • Exercise 4 -- Identify the differences between running containers myapache and builtapache

a. How were the two containers started?

b. Which is the command running?

c. Attach to the two containers and verify the PID of the command.

d. What happens when typing exit from these two apache containers?

  • Exercise 5 -- Create your "cowsay" container

Write a Dockerfile so that:

- The container downloaded in Exercise 1 is used as the base image;

- "cowsay" is installed in the container;

- The container can run interactively and "cowsay" can be invoked from a bash shell

  • Exercise 6 -- Create a "cowsay" container that prints a user-defined sentence

Modify the previous Dockerfile so that:

- The sentence said by the cow can be specified by the user via an environment variable

- A default sentence is defined, in case the user does not specify any custom sentence

- The container can be executed in a detached way and exits after printing the sentence

  • Exercise 7 -- Create a "cowsay" container that reads sentences from a file

Modify the previous Dockerfile so that:

- The sentences said by the cow are stored in a text file (one line == one sentence)

- The file is not stored in the Docker image but must be copied in the container manually

- Between one sentence and the following, a sleep time is enforced. The duration of the sleep time can be configured via an environment variable

- The container can be executed in a detached way and exists after the cow has read all the sentences form the file

- Bonus: Define additional parameters (e.g., the path of the file with the sentences) via environment variables

- Bonus2: Handle errors (e.g., the file with sentences is not there, the file is empty, ...)