Configuration and Secrets in Compose: environment, env_file, .env Interpolation, secrets and Profiles
.env is the file Compose reads to fill ${VAR} expressions in compose.yaml and it gives nothing to containers; passing environment variables to a container is the job of environment and env_file, passing a password as a file is the job of secrets:. With real output we look at precedence, required variables with ${VAR:?}, moving Bookstore's passwords to /run/secrets, appsettings through configs and optional services with profiles.
14 Nov 2026
·
11 min
·
15