Interview Prep/Docker/Containers that exit, crash or misbehave

Container shows `Up` but the app returns 502 / connection refused from the host on published port.

IntermediateTroubleshootingContainers that exit, crash or misbehave
Answer

Likely causes → App listens on 127.0.0.1 inside the container instead of 0.0.0.0, wrong container port, or the app hasn't finished booting.

Diagnose →

docker exec c ss -tlnp
docker port c
curl -v localhost:8080

Fix → Bind the app to 0.0.0.0 (e.g. flask run --host 0.0.0.0) and publish the right port.

Prevent → Add a health check hitting the published path.

All Docker questions Roadmap: Docker & containers

More on Containers that exit, crash or misbehave