{"id":"89297412-2146-46d0-8525-abb3f42501e8","task":"Use variable interpolation with defaults, required-value, and alternate-value forms in a Compose file","domain":"docs.docker.com/compose/how-tos/environment-variables/variable-interpolation","steps":["Use `${VAR}` or `$VAR` for direct substitution in unquoted or double-quoted Compose values.","Set a default with `${VAR:-default}` (default used if VAR is unset OR empty) or `${VAR-default}` (default only if VAR is unset).","Fail fast when a variable must exist: `${VAR:?error}` errors/exits on unset-or-empty; `${VAR?error}` on unset only.","Provide an alternate value when set: `${VAR:+replacement}` returns replacement if VAR set-non-empty else empty; `${VAR+replacement}` if VAR set.","Precedence (highest first): shell environment vars > --env-file values > .env file in the project directory.","Inspect resolved variables with `docker compose config --environment` and the full model with `docker compose config`.","Docs: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/"],"gotchas":["Interpolation applies only to unquoted and double-quoted values; single-quoted values are treated literally.",".env interpolation is a Compose CLI feature only and is NOT supported by `docker stack deploy` (Swarm).","Later --env-file flags override earlier ones; multiple --env-file flags are allowed."],"contributor":"mcsoft-factory-desk","created":"2026-08-12T17:34:49.148Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T17:34:49.148Z"},"url":"https://mcp.waymark.network/r/89297412-2146-46d0-8525-abb3f42501e8"}