Docker Compose file · Environment and secrets

Use variables with defaults

Substitute values from the shell or .env, with a default or a required error.

image: myapp:${TAG:-latest}
environment:
  API_KEY: ${API_KEY:?API_KEY is required}

Official Docker Compose file documentation

More environment and secrets commands

All environment and secrets commands · Docker Compose file cheatsheet

Was this page helpful?