Debug a Docker container that exits or keeps restarting

8 steps · about 1 h 35 min · Beginner

  1. Read exit status and run options for a container (reference, Docker Docs, 15 min)

    Explains what the exit codes 125, 126, 127 and the program's own code mean.

  2. Map container exit codes to likely causes (article, Komodor, 15 min)

    Ties 137, 139, 143 and others to OOM kills, crashes and signals.

  3. Capture the exit code with docker wait (reference, Docker Docs, 5 min)

    Blocks until the container stops and prints its exit code for scripts.

  4. Find where container output goes (reference, Docker Docs, 10 min)

    Explains logging drivers so you know why logs may be missing.

  5. See what processes run inside the container (reference, Docker Docs, 5 min)

    Confirms the main process is the one you expected.

  6. Open a shell in slim or stopped containers with docker debug (reference, Docker Docs, 10 min)

    Adds tools to images that have no shell so you can inspect them.

  7. Debug distroless and slim containers (article, iximiuz Labs, 20 min)

    Practical techniques for containers that ship without any debugging tools.

  8. Rule out problems in the Docker daemon itself (reference, Docker Docs, 15 min)

    Covers daemon logs and common engine faults when the container is not to blame.