Skip to content

About

Projects as exercises for Docker training

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Latest commit

 

History

52 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker training projects

Hands-on exercises to learn Docker by solving small, realistic problems. They are meant both for people learning Docker on their own and for teachers who want ready-made exercises for their courses. Everything is licensed under GPLv3, so feel free to use and adapt it.

Every exercise has a reference solution that is tested in CI on each change and every week, so it keeps working with current versions of Docker and of the images it uses.

How each exercise is organized

Each exercise lives in a numbered directory:

  • README.md: the problem to solve, the deliverables, and how to check that your solution works.
  • src/ (optional): files you start from.
  • sol/: one possible solution. There are usually several valid ones, so treat it as a reference, not as the only answer.
  • sol/test.sh: a script that builds and runs the solution and checks that it works. CI runs it on every change.

The goal is to find a simple, working solution to the problem as stated. Features like volumes or extra containers are only needed when the problem asks for them.

Requirements

  • Docker Engine with the Compose plugin (docker compose), or Docker Desktop.
  • Bash, to run the run.sh and test.sh scripts.
  • An internet connection, to pull images and packages.

For learners

  1. Pick an exercise from the index. The level gives an idea of the order, but the exercises in a sequence (02 → 03, 08 → 09 → 10) build on each other.
  2. Read its README.md and try to solve it without looking at sol/.
  3. Check your solution with the steps in the exercise's README.
  4. Compare it with the one in sol/. If yours is different but works, that's fine.

For teachers

  • Each exercise is self-contained and can be handed out as is: give students the exercise's README.md and src/ directory.
  • The concepts column in the index helps to match exercises to the topics of each session.
  • sol/test.sh checks a solution automatically. You can adapt it to check your students' solutions.
  • Suggestions and new exercises are welcome (see How to contribute).

Index of exercises

# Exercise Level Concepts
01 Fix the build of an image of a complete WordPress installation Beginner Dockerfile, image layers, reading build errors
02 Deploy WordPress and MySQL in two containers Beginner Official images, networks, volumes, environment variables
03 Orchestrate exercise 02 with Docker Compose Beginner Docker Compose, healthchecks
04 Build a Nextcloud image and deploy it with MariaDB, Redis and background jobs Advanced Building a complex PHP app image, entrypoint scripts, volumes for state
05 Deploy an Nginx reverse proxy in front of two web servers with different PHP versions Intermediate Several images, networks, reverse proxy, virtual hosts
06 Build a monitoring image that runs atop in the host PID namespace Intermediate Namespaces, --pid host
07 Build an Apache web server image with PHP support Beginner Writing a Dockerfile, logs, bind mounts
08 Build the image of a Flask app for a development environment Beginner Language images, layer caching, bind mounts
09 Deploy a CRUD app based on Flask and Vue.js with Docker Compose in production Advanced Multi-stage builds, production servers, reverse proxy, Docker Compose
10 Test the API of the exercise 09 app with Hurl Intermediate Tooling images, ENTRYPOINT and CMD, container networking
11 Design a multi-stage image that builds and runs a simple Go app Intermediate Multi-stage builds, minimal images, non-root users
12 Make an Nginx image run without root, capabilities or a writable filesystem Intermediate Non-root users, read-only filesystems, Linux capabilities
13 Use a token during a build without leaving it in the image Intermediate BuildKit build secrets, build arguments, image history
14 Speed up the build of a Node.js app Intermediate Layer caching, .dockerignore, BuildKit cache mounts, production dependencies
15 Build and publish a Go image for amd64 and arm64 Advanced Multi-platform images, Buildx builders, cross-compilation
16 Find and fix the vulnerabilities of an old Python image Intermediate Vulnerability scanning, base images, dependency updates
17 Make a service stop gracefully and report its health Intermediate PID 1, signals, exec, zombie processes, init processes, healthchecks

Note on security

To keep the focus on the problem being solved, passwords and credentials in these exercises are written in clear text.

Never do this in production or in any sensitive environment. Use a secrets management solution instead, such as Docker secrets, BuildKit build secrets, HashiCorp Vault or your cloud provider's secret manager.

How to contribute

New exercises and improvements are welcome. To keep the repository consistent:

  1. Create a directory named with the next number after the last one in the repository.
  2. Add a README.md with the problem, the expected deliverables and how to check the solution. Use an existing exercise as a template.
  3. Add any starting files in src/ and a working solution in sol/.
  4. Add a sol/test.sh script that builds and runs the solution and fails if it doesn't work, and add the exercise to the matrix in .github/workflows/exercises.yml. If the exercise has Dockerfiles, Compose files or dependency files, add their directories to .github/dependabot.yml too.
  5. Add the exercise to the index above, with your name and a contact email or URL in parentheses.

Solution Dockerfiles are linted with hadolint using the rules in .hadolint.yaml.

License

GPLv3

About

Projects as exercises for Docker training

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages