Docker Compose "invalid interpolation format" in CI
Compose interpolates ${VAR} references in the compose file. A malformed reference - an unterminated ${X with no closing brace, or an unexpected character inside the braces - fails interpolation with invalid interpolation format.
What this error means
A docker compose up/config fails with invalid interpolation format for <key>. A variable reference is unterminated or malformed.
invalid interpolation format for services.api.environment.URL: "${X". You may need to escape any $ with another $.Common causes
An unterminated variable reference
A ${X without a closing } cannot be interpolated.
A literal $ that should be escaped
A literal dollar sign in a value must be written as $$ so Compose does not read it as interpolation.
How to fix it
Close or correct the variable reference
- Terminate the
${VAR}with a closing brace. - Use the correct variable name.
services:
api:
environment:
URL: "${X}"Escape literal dollar signs with $$
- Double any literal
$so Compose treats it as a literal, not interpolation.
services:
api:
environment:
PROMPT: "cost is $$5"How to prevent it
- Always terminate ${VAR} references with a closing brace.
- Escape literal dollar signs as $$.
- Validate with
docker compose configbefore deploy.