advancedScenario-Based & System Design Questions

A service works correctly when run with `docker run` directly but behaves differently (wrong config, missing env vars) when started via `docker compose up`.

Check whether the compose.yaml is missing `environment:`/`env_file:` entries that were being passed manually via `-e` flags in the direct `docker run` command, or whether a `.env` file in the Compose project directory is silently overriding expected values — `docker compose config` is useful here to print the fully resolved configuration and spot the discrepancy directly.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to A container running as a non-root user fails to write to a mounted volume with a permission denied error.← Back to all Docker questions