`docker exec` fails with `cannot exec in a stopped container` or `container is not running`.
BeginnerTroubleshootingContainers that exit, crash or misbehave
Answer
Likely causes → Container crashed or exited.
Diagnose → docker ps -a, docker logs c, docker inspect -f '{{.State.Error}}' c.
Fix → Find out why it exited; to inspect its filesystem use docker cp c:/path . or docker run --rm -it --entrypoint sh image.
Prevent → Alert on restart count.
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