Skip to content
Latchkey

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.

docker
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

  1. Terminate the ${VAR} with a closing brace.
  2. Use the correct variable name.
docker-compose.yml
services:
  api:
    environment:
      URL: "${X}"

Escape literal dollar signs with $$

  1. Double any literal $ so Compose treats it as a literal, not interpolation.
docker-compose.yml
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 config before deploy.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →