46/53
Sign inSign up free

830. Stop Copy-Pasting Compose Settings

easy 10 XP ~8 minHands-on lab

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

The four services in /home/student/projects/label-printer/compose.yaml each repeat their logging and restart settings. Two have drifted: scheduler keeps 100 MB log files (the disk filled up), and web uses restart: always.

Task

  • Define the shared settings once, in a top-level extension field (a key starting with x-) with a YAML anchor, and use it in all four services.
  • Every service ends up with: restart: unless-stopped, and logging driver json-file with options max-size: 10m and max-file: "3".
  • max-size may appear only once in the file. Keep each service's image and other settings.

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.