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.
More on Networking and Compose
Containers on the default bridge cannot resolve each other by name. Why, and what do you do?BeginnerHow do you expose a container only to the local host, not the internet?BeginnerDesign a Compose file for web + api + postgres + redis with correct startup ordering.IntermediateFrontend must reach the API but not the database. Segment the network.IntermediateA container needs to call a service running on the Docker host.BeginnerWhen would you use `--network host`?Intermediate