Docker · tool · fg-0268

Variables from the Compose project dotenv file are substituted into the YAML but missing inside the container

If you see printenv inside the container does not list the variable, the cause and the fix for Docker are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
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

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun