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

Debug a container that crashes before you can `exec` into it.

IntermediateTroubleshootingContainers that exit, crash or misbehave
Answer

Likely causes → Startup error.

Diagnose →

docker logs --tail 200 c
docker run --rm -it --entrypoint sh image
docker commit c debug-img && docker run --rm -it --entrypoint sh debug-img
docker run --rm -it --volumes-from c --entrypoint sh image

Fix → Reproduce with the same env and mounts, run the entrypoint manually (sh -x /entrypoint.sh).

Prevent → Make entrypoints verbose on error and log configuration validation.

All Docker questions Roadmap: Docker & containers

More on Containers that exit, crash or misbehave