49/53
Sign inSign up free

843. Variables in Compose, the Right Way

medium 20 XP ~11 minHands-on lab

Labs have no container engine, so nothing is started: your files are checked with docker-compose config.

/home/student/projects/checkout-web/compose.yaml has the database password written into it twice, always deploys latest, and mixes app settings into the file.

Task

  • The api image tag comes from the variable TAG, defaulting to stable when it's unset or empty.
  • The password comes from the variable DB_PASSWORD, used for both POSTGRES_PASSWORD and inside DATABASE_URL. When DB_PASSWORD is unset or empty, docker compose config (and up) must fail with an error. Don't store the password in the project directory (no .env with it).
  • LOG_LEVEL=info and FEATURE_FLAGS=search,export move out of compose.yaml into a file api.env that the api service loads.
  • The word changeme must not appear in compose.yaml anymore.

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.