10/53
Sign inSign up free

426. Run the Container as a Non-Root User

easy 10 XP ~5 minHands-on lab100% acceptance

Labs have no container engine, so nothing is built or started: your files are checked by reading them, the way a reviewer or a CI linter would. docker-compose config (to validate Compose files) and hadolint (a Dockerfile linter) are installed.

A security scan flagged the image of /home/student/projects/mailer: the Python app runs as root.

Task

Change the Dockerfile so that:

  • it creates a system user app (and group app) with UID 10001
  • /app and everything copied into it belong to that user
  • the container runs as that user: the last USER before the start command is app or 10001
  • nothing after that switches back to root
  • hadolint no longer reports DL3002 (last user should not be root)

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.

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.