• Exercise 1 -- Web Server with persistent storage

Create a Dockerfile and a yaml file for docker-compose describing a container with:

a. a web server (e.g., apache or nginx) serving static web content from /var/www/html;

b. the files at /var/www/html must be stored on a dedicated volume;

c. the container must be able to run in detached mode.

  • Exercise 2 -- Web Server with mounted host path

Modify (where needed) the previous Dockerfile and yaml file so to mount a path on the host machine to /var/www/html in the container.

a. What happens if the folder on the host does not exist?

b. What happens if the folder is left empty?

c. What happens if the container of the folder on host is changed while the container is running?

  • Exercise 3 -- Highly-available web server with independent front- and back-end containers

Create one or multiple Dockerfiles and a yaml file to instantiate a highly-available web server where:

a. The front-end server is an apache reverse proxy running in a container configured to auto-restart in case of errors. This container is also equipped with a healthcheck that polls the server every 30 seconds;

b. The back-end is made of replicated web servers (assume 3 replicas as initial state) serving content from /var/www/html;

c. All the backend servers read content from a shared storage volume mounted in read-only mode;

d. An additional container mounts the storage volume in read-write mode and is responsible for populating it by pulling content from a git repository. The check of new content takes place every 60 seconds.