Skip to content
StackDecode
AdvancedLesson 23 of 26

Debugging containers

A systematic way to find out why a container misbehaves.

  1. docker ps -a: did it exit? What was the status code?
  2. docker logs <c>: read the last output.
  3. docker inspect <c>: environment, mounts, OOMKilled, exit code.
  4. docker exec -it <c> sh: look around. Minimal images may have no shell.
  5. 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 out

Exit code 137 usually means killed (often out of memory); 139 is a segmentation fault; 1 is a generic app error.