<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
fernandoteixxeira/stark-bank-challenge/docker-compose
──Details
PublishedOctober 23, 2026 at 11:26 PM
Content Hashsha256:429254542beb7b0b...
Git SHA0369fa0622b1
──Files
Files (1 file, 4.1 KB)
SKILL.md4.1 KBactive
SKILL.md · 107 lines · 4.1 KB

version: "1.0.0" name: docker-compose description: Use when composing multi-container setups — service dependencies and healthchecks, network aliases, variable substitution and .env, exit codes from a one-shot job, and volumes.


Docker Compose

Runs several containers together. For the image itself see dockerfile; for containers started from a test see testcontainers.

Dependencies Are Not Readiness

depends_on alone waits for the container to start, not for the process inside to be ready. That is a race, and it is the usual cause of "works on my machine".

yaml
services:
dependency:
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8080/health"]
interval: 2s
timeout: 3s
retries: 15
app:
depends_on:
dependency:
condition: service_healthy

For a one-shot container that must finish first, use condition: service_completed_successfully.

Exit Codes Lie by Default

sh
docker compose up --abort-on-container-exit --exit-code-from app

--exit-code-from app reports 0 when `app` never ran at all — for example because its dependency failed a healthcheck. A CI step that trusts it reports green for a run that did not happen.

Read the container's own status instead:

sh
docker compose up --build --abort-on-container-exit --exit-code-from app
docker compose ps -a --format json app | jq -r 'if .State == "exited" then .ExitCode else "did-not-run" end'

Anything other than 0 is a failure, including the container never being created.

Network Aliases

yaml
services:
mock:
networks:
default:
aliases:
- some.host.name

Every container on that network now resolves some.host.name to mock. This is how a client with a compiled-in host is redirected without touching its configuration — see tls-local-mocking, since https needs the certificate to follow.

Aliases work container to container. A process on the host resolves through the host's own resolver and is unaffected.

Variables and .env

Compose substitutes ${VAR} from the environment and from .env in the project directory, before the file is parsed.

yaml
environment:
OPTIONAL: "${OPTIONAL:-a default}"
REQUIRED: "${REQUIRED:?a message naming what to set}"

:? fails the run at parse time with your message. Use it for anything whose absence would otherwise become a confusing error from inside the container.

Quote the value when the message contains a colon. YAML reads KEY: ${VAR:?run: this command} as a nested mapping and fails with mapping values are not allowed in this context, pointing at the line rather than at the colon.

Note the difference between the two ways a variable reaches a container:

  • ${VAR} in the compose file — substituted by Compose, reads .env automatically.
  • env_file: — passed straight to the container, no substitution and no multi-line values. A PEM does not fit; base64 does.

Multiple Compose Files

docker compose -f other-compose.yml up selects a different file. Useful when one setup is safe and another is not — a mock that cannot reach the real service, versus one that can and will.

Prefer that split over a flag. A file that reaches production is a file worth being hard to run by reflex, and worth keeping out of the repository if the credentials are not there either.

Volumes

yaml
volumes:
- ./file:/in/container:ro # bind mount, host ownership preserved

A bind-mounted file keeps its host UID and mode. A mode-600 file owned by you is unreadable to a container running as its own non-root user, and the process reports whatever it does when a file is missing — rarely "permission denied".

Always :ro for anything the container should not write.

Review Checklist

  • depends_on uses a condition, not the bare form.
  • CI reads the container's exit status, not Compose's.
  • Required variables use :? with a message that names the fix.
  • Values containing a colon are quoted.
  • Bind-mounted files are readable by the container's user.
  • A compose that can reach production is separate, and named so nobody runs it by accident.
All versions