How do you handle configuration and secrets in Compose?
⚡
Quick Answer
Use environment variables (via env_file or a .env), and Compose secrets for sensitive values.
Detailed Answer
Non-sensitive config goes in environment: or an env_file. The top-level .env feeds variable interpolation like ${TAG}. For secrets, Compose secrets mount files into /run/secrets rather than baking values into the image or env, which are more exposed. Never commit real secrets.
💡
Interview Tip
Distinguish .env (interpolation) from env_file (container env).
docker-composeenvsecrets