- Symptom
- printenv inside the container does not list the variabledocker compose config shows the value already substituted into the file
- Cause
- Compose reads the dotenv file in the project directory only to fill ${VAR} references in the Compose file, and --env-file only changes which file feeds that substitution. Nothing reaches a container unless a service lists it under environment or env_file.
- Fix
- Reference each variable under environment, or point the service at the file with env_file.
- Apply
services: api: env_file: app.env environment: DATABASE_URL: ${DATABASE_URL}- Affected
- Docker Compose v2, as of October 2026
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders