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.
More on Containers that exit, crash or misbehave
Container exits immediately with code 0 right after `docker run -d`.Beginner`Exited (137)` with no OOM flag.Intermediate`Exited (139)` segmentation fault.Advanced`Exited (126)` / `Exited (127)`.Beginner`exec /entrypoint.sh: exec format error`Intermediate`docker run` says `WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)` and the app is very slow.Beginner