Q: A container exits with code `137`. What does this specific code universally mean in the Docker ecosystem, and where should you look next?
Exit code 137 specifically means the container received a SIGKILL (signal 9) and was abruptly terminated ($128 + 9 = 137$).
Want to master this scenario in a live sandbox? KodeKloud's Docker Certified Associate (DCA) Hands-On Lab Course covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: "During an image optimization initiative across our services, we solved this exact problem. The interviewer is testing: Exit code evaluation, OOM killer.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third."
Production Solution & Architecture
Exit code 137 means the container's main process received SIGKILL (signal 9) and was terminated immediately (128 + 9 = 137). The most common sender is the kernel OOM (Out Of Memory) Killer, which fires when the container exceeds its memory limit. A docker kill, a docker stop that outlived its grace period, or an orchestrator force-stop produce the same code. Next steps: run docker inspect and check the State.OOMKilled flag to tell them apart.
docker inspect --format '{{.State.OOMKilled}} {{.State.ExitCode}}' <container_id>
dmesg -T | grep -i -E 'oom|killed process'
- OOMKilled is true: The container hit its memory limit. Profile the application and review the
-mlimit; checkdmesg -T | grep -i oomon the host. - OOMKilled is false: Look for a forced stop.
docker stopsends SIGTERM, then SIGKILL after 10 seconds, so an app that ignores SIGTERM exits with 137. - Host memory pressure: The host can run out of memory and kill a container that was under its own limit. Check host memory and the limits of its neighbours.
- Immediate triage: exit code 137 means the container received SIGKILL (128 + 9); confirm with State.OOMKilled.
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Assuming every exit code 137 is an out-of-memory kill A forced docker kill or a docker stop that outlived its 10 second grace period also exits 137. Check State.OOMKilled before changing limits.
- Raising the memory limit before profiling the application A leak survives a bigger limit and only fails later. Use docker stats and application profiling to find what is growing.
- Running the app under a shell wrapper or npm start as PID 1 that does not forward SIGTERM docker stop waits 10 seconds and then sends SIGKILL, so every restart ends in 137. Use exec form, exec, or docker run --init.
- Forgetting that tmpfs mounts and page cache count toward the container's memory Heavy writes to a tmpfs or /dev/shm can trigger an OOM kill even when the application heap looks small.