Docker — Production Errors, Mistakes and Recovery

Docker exit codes, OOM kills, stop signals, full disks, registry, network and daemon errors, decoded from the Docker docs. Plus the mistakes (prune, overwritten tags, baked-in secrets) and how to recover.

Overview

Docker failures in production fall into a small number of shapes. A container exits with a number you have to decode. A host fills its disk with images, build cache and logs nobody rotated. A pull fails because of a rate limit, a missing tag or the wrong CPU architecture. A stop takes ten seconds and ends in a kill. And a large share of incidents are not errors at all: someone pruned a volume, overwrote :latest, baked a token into a layer or ran a command against the wrong host.

The idea to keep: an exit code or an error string tells you which layer failed. 125 is the Docker daemon or its CLI flags, 126 and 127 are the command you asked it to start, 128 + n means signal n killed the process, and anything else is your program. 137 is 128 + 9, a SIGKILL, and the container state says whether the kernel OOM killer sent it: OOMKilled true means the memory limit was hit, false means the stop timeout or a kill. Read the number first, then open the right layer.

What you will be able to do

  • Decode exit codes 0, 1, 125, 126, 127, 137, 139 and 143 and say which layer produced each.
  • Tell an OOM kill from a stop-timeout kill with docker inspect and docker events.
  • Fix the PID 1 signal problem that turns every docker stop into a 10-second wait and a 137.
  • Find what is filling the disk with docker system df and clean it without deleting data.
  • Diagnose pull failures: rate limits, authentication, missing manifests and platform mismatches.
  • Explain what a prune, docker rm -v or an overwritten tag destroys, what can be recovered, and which guardrails prevent it.

Key concepts

  • Exit 125, 126, 127
  • 128 + n
  • OOMKilled
  • Stop timeout
  • PID 1 and --init
  • Dangling image
  • Anonymous vs named volume
  • Image digest
  • Immutable tags
  • Build secret mount

Interview questions

  • A docker image tag my app:latest was overwritten in the registry and now a rollback to the previous version is impossible. How should the repo have been configured to prevent this, and can you still recover the old image?
  • Someone ran docker system prune -a --volumes on a production host. What was lost, what can you recover, and how do you prevent it?
  • A container exits with code 137 a few seconds after docker stop. What is happening?
  • A container keeps restarting with exit code 137 under load. How do you decide between a memory problem and something else?
  • A Docker host is out of disk. Walk me through reclaiming space safely.
  • CI started failing with HTTP 429 "You have reached your pull rate limit" when pulling base images. What do you do?
  • An image works on a developer laptop but fails in production with exec format error. Why?
  • Two containers on the same host cannot reach each other by name, but the IP works. What is wrong?
  • A security scan found an API key in a production image. The Dockerfile deletes the file in a later step. What do you do?
  • docker commands fail with Cannot connect to the Docker daemon. How do you troubleshoot?
  • A teammate fixed a production bug by running docker exec and editing a file inside the container. Why is that a problem, and what should happen instead?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio