AdvancedLesson 23 of 26
Debugging containers
A systematic way to find out why a container misbehaves.
docker ps -a: did it exit? What was the status code?docker logs <c>: read the last output.docker inspect <c>: environment, mounts,OOMKilled, exit code.docker exec -it <c> sh: look around. Minimal images may have no shell.- Override the entrypoint to explore a broken image.
bash
docker run --rm -it --entrypoint sh myapp:1.0
docker diff <c> # files changed vs the image
docker cp <c>:/app/log.txt . # copy a file outExit code 137 usually means killed (often out of memory); 139 is a segmentation fault; 1 is a generic app error.