Sign inSign up free

515. Harden a Service in Compose

medium 20 XP ~10 minHands-on lab

There is no container engine in this lab: docker compose isn't available, but docker-compose config validates and prints the merged configuration, which is what the grader reads.

A penetration test flagged the api service in /home/student/projects/mailer/compose.yaml: it runs as root with every default capability and a writable filesystem, and it can use all the host's memory.

Task

Change the api service (keep its image and port) so that it:

  • runs as user and group 10001:10001,
  • has a read-only root filesystem, with a tmpfs mounted at /tmp so it can still write temporary files,
  • drops all Linux capabilities,
  • can't gain new privileges (the no-new-privileges security option),
  • has a memory limit of 256 MB (256m),
  • restarts automatically unless someone stopped it (unless-stopped).

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Part of Docker Fundamentals. Next step: The Database Is on the Internet

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.