Interview Prep/Docker/Networking and Compose

The app works with `docker run` but inside Compose cannot read an env var.

BeginnerScenarioNetworking and Compose
Answer

Situation read → Compose interpolates ${VAR} from the shell and .env; environment: and env_file: differ.

What I'd do → Check with docker compose config to see resolved values; use env_file: .env.app for container env and .env for substitution in the compose file itself. Quote values with spaces.

Why → .env is for Compose-file variables unless you also list it under env_file.

Interview tip → Precedence: shell > environment > env_file > image ENV.

All Docker questions Roadmap: Docker & containers

More on Networking and Compose