Linux Labs

Containers: Docker and compose / Stage 8 of 11

docker compose: a stack in one file

Not running Starting usually ~20 s
Leave the lesson

Step 3 of 7 · on a machine · 5 min

Editing and re-creating

The cause is in the file. Here: how compose applies an edit.

A container gets its environment, ports and image when it is created: they can only change with a new container. docker compose up -d does that on its own — it compares each service's description with its container. The description changed — Recreate: the old container is removed and a new one is created in its place. It did not change — Running, and the container stays as it is.

docker compose restart <service> restarts the same container, and compose.yaml is not read: the environment stays as it was. restart is for another case — when a file mounted into the container through volumes has changed. The program rereads such a file when it starts, and up -d does not compare its contents.

Exercise · do it

Fix backend

Make backend run and curl http://localhost:8080/ answer with its page, backend: production. The stack is ~/stack/compose.yaml; leave the application code in ~/stack/app alone.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Run backend with a corrected environment not done yet
  • Get the site's requests through to backend not done yet

Step goals

0 of 2
  • Run backend with a corrected environment — not done yet
  • Get the site's requests through to backend — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Run backend with a corrected environment — not done yet
  • Get the site's requests through to backend — not done yet
Loading…