Fix Docker Exit Code 137 (Container Killed / OOM)
Exit 137 usually means the kernel shot your container for eating too much memory. Here's how to confirm the OOM kill and stop it happening again.
Key takeaways
- Exit code 137 means the container received SIGKILL, which is 128 plus signal 9, usually from the kernel OOM killer.
- Confirm it with docker inspect and the OOMKilled field, then check dmesg to tell a container limit from host exhaustion.
- Fix it by sizing --memory from measured peaks and making the runtime heap cgroup-aware.
On this page
Exit code 137 means your container got SIGKILL (128 + 9), almost always from the kernel OOM killer. Run docker inspect --format '{{.State.OOMKilled}}' myapp; if it prints true, raise --memory to the measured peak plus headroom, set --memory-swap to the same value, and cap the runtime heap below the limit. If it prints false, something killed it on purpose.
Verified against
Docker Engine 29.9.2 (released 2026-10-20), Node.js 26.13.0, against the docs.docker.com resource constraints and docker container inspect pages, the signal(7) man page and the Node.js CLI reference. Checked October 2026.
This failure looks scary and is actually legible once you know how to read it. Application logs are usually useless here, because the app never got a chance to log anything. It didn't crash. Something outside it pulled the trigger.
What 137 actually means
Exit codes above 128 encode a signal. The math is 128 + signal_number. Signal 9 is SIGKILL, so 128 + 9 = 137. SIGKILL is the one signal a process cannot catch, block, or handle. When your container gets it, the process is gone instantly with no cleanup, no shutdown hook, no final log line.
The usual sender of that SIGKILL is the Linux OOM (out-of-memory) killer. When memory runs out, the kernel picks a process and kills it to reclaim RAM. In a Docker world "memory runs out" happens at two very different boundaries, and telling them apart is the whole job.
Confirm it's actually an OOM kill
Don't guess. Ask Docker directly:
$ docker inspect --format '{{.State.OOMKilled}}' myapp
true
If that prints true, the kernel OOM-killed your container. Full stop. You can see the same thing in the raw state:
$ docker inspect --format '{{json .State}}' myapp | jq
{
"Status": "exited",
"OOMKilled": true,
"ExitCode": 137,
"Error": ""
}
Then confirm on the host kernel side with dmesg:
$ dmesg -T | grep -i -E 'oom|killed process'
[Tue Jul 7 14:22:10 2026] Memory cgroup out of memory: Killed process 48213 (node) total-vm:2891044kB, anon-rss:1048180kB
[Tue Jul 7 14:22:10 2026] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=...
That constraint=CONSTRAINT_MEMCG is the tell. MEMCG means the kill came from a memory cgroup hitting its limit, which is the container's own --memory cap. If instead you see constraint=CONSTRAINT_NONE, the whole host ran out of memory and the kernel went hunting for the biggest target. Same exit code, completely different fix.
Two kinds of OOM, two fixes
The container hit its own limit. You told Docker --memory=512m and the process wanted more. The cgroup limit is doing exactly its job. Check what it's really using:
$ docker stats --no-stream
CONTAINER NAME CPU % MEM USAGE / LIMIT MEM %
a1b2c3d4 myapp 0.42% 509.8MiB / 512MiB 99.57%
Sitting at 99% against the limit right before it died is your smoking gun. Either the limit is too low for honest workload, or the app is leaking.
The host ran out. No per-container limit, or limits that sum to more than physical RAM, and everything competes. Here the container that gets killed often isn't the one at fault, it's just the fattest. Check the host:
$ free -m
total used free shared
Mem: 7820 7511 120 210
120MB free on an 8GB box means you're overcommitted and living on borrowed time.
Right-size the limit from real numbers
The lazy fix is to bump --memory until the kills stop. Don't. Measure first, then set a limit with headroom over the real steady-state peak:
$ docker run -d --name myapp \
--memory=1g \
--memory-swap=1g \
myapp:latest
Setting --memory-swap equal to --memory disables swap for the container, which is what you usually want in production. If you set --memory and leave --memory-swap unset, Docker's docs say the container can use as much swap as its memory limit (if the host has swap), so the total doubles, quietly hiding the real footprint until swap thrashing tanks your latency instead. The floor, for what it's worth, is 6m; anything lower is rejected. Be deliberate about it.
Make the runtime aware of the cgroup
This is the trap that catches people who "already set a limit." Older runtimes look at the host's total RAM, not the container's cgroup limit, and size their heap for a machine that doesn't exist. A JVM on an 8GB host inside a 1GB container will happily plan a 2GB heap and get shot the moment it grows into it.
Tell the runtime the truth:
# JVM: size the heap as a fraction of the CGROUP limit, not the host
$ java -XX:MaxRAMPercentage=75.0 -jar app.jar
# Node: cap the old-space heap under your container limit
$ node --max-old-space-size=768 server.js
For a 1GB container, --max-old-space-size=768 leaves room for the non-heap overhead (buffers, native modules, the V8 baseline) that lives outside the old space and still counts against your cgroup. Set it to the full 1024 and you've reserved zero headroom for everything else. Node's docs also list --max-old-space-size-percentage, but they define it as a percentage of "available system memory" without mentioning cgroups, so we stick with an explicit MiB value inside containers until you've confirmed what it reads on your version.
When it's a real leak
If usage climbs steadily and never plateaus, no limit will save you, it just changes how long until the kill. Watch the slope over time:
$ docker stats myapp
CONTAINER MEM USAGE / LIMIT
myapp 412MiB / 1GiB # 10:00
myapp 587MiB / 1GiB # 10:30
myapp 761MiB / 1GiB # 11:00
A line that only goes up is a leak. Fix the code. The limit is a seatbelt, not a cure.
Don't overcommit the host
If you run several containers on one box, their limits should sum to comfortably less than physical RAM, with slack for the kernel, page cache, and the Docker daemon itself. Overcommitting on the promise that "they won't all peak at once" works right up until they do, and then the host-level OOM killer makes the choice for you, badly.
One more thing: 137 isn't always the kernel
If OOMKilled is false but the exit code is still 137, something sent SIGKILL by hand. A docker kill myapp (which sends SIGKILL by default), an orchestrator killing a container that ignored SIGTERM during shutdown, or a docker stop that timed out and escalated. Same number, no OOM involved. That's exactly why you check .State.OOMKilled first instead of trusting the code alone.
If you're chasing a broader set of failures, our Docker troubleshooting guide covers the neighboring exit codes. And the container-orchestrator version of this exact problem shows up as Kubernetes OOMKilled, where the pod status says it plainly and the cgroup mechanics underneath are identical.
Where this breaks
Docker Desktop on macOS and Windows runs containers in a VM, so dmesg on your laptop shows nothing; the kill happened inside the VM, and the VM's own memory setting is a third ceiling above --memory. Under Kubernetes the same signal surfaces as OOMKilled in pod status and docker inspect is not the tool, which is why Kubernetes exit codes is the better map there.
Questions people ask
What does exit code 137 mean in Docker?
It means the main process received SIGKILL. Exit codes above 128 encode a signal as 128 plus the signal number, and the signal(7) man page lists SIGKILL as 9. The usual sender is the kernel OOM killer when the container exceeds its --memory limit or the host runs out of RAM. A manual docker kill or a timed-out docker stop produces the same code.
How do I know if Docker killed my container for memory?
Run docker inspect --format '{{.State.OOMKilled}}' <container>. true confirms an OOM kill. Then check dmesg -T | grep -i oom on the host: CONSTRAINT_MEMCG means the container hit its own cgroup limit, while CONSTRAINT_NONE means the whole host ran out and the kernel picked a victim. Those two causes need different fixes.
Exit code 137 but OOMKilled is false. Why?
Something sent SIGKILL deliberately. Common senders are docker kill, docker stop escalating after the 10-second grace period when the process ignored SIGTERM, and orchestrators enforcing their own shutdown timeout. Check docker events --since 1h for a kill or stop event, and make your process handle SIGTERM so it exits cleanly before the escalation.
The call we'd make
Run docker inspect --format '{{.State.OOMKilled}}' before you touch anything else. If it's true, check dmesg for CONSTRAINT_MEMCG versus CONSTRAINT_NONE to know whether it was the container's limit or the whole host. Set an explicit --memory with --memory-swap equal to it, size it from docker stats peaks plus headroom, and make the runtime cgroup-aware with MaxRAMPercentage or --max-old-space-size. If memory only ever climbs, stop tuning limits and go find the leak.
Sources
Cite this article
Kiril Urbonas (2026). Fix Docker Exit Code 137 (Container Killed / OOM). DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/fix-docker-oom-137
[Fix Docker Exit Code 137 (Container Killed / OOM)](https://www.devopsness.com/blog/fix-docker-oom-137) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
kaniko CVE-2026-105769: Lookalike ACR Hosts Get Your Azure Token. Rebuild on v1.25.20
A FROM line pointing at a host like x.azurecr.io.attacker.com is enough to make kaniko hand the build's Entra ID token to that host. Which kaniko forks and images are affected, how to find Azure identities in your build pods, and what to rotate.
Sign Container Images With Cosign: Keyless GitHub Actions Workflow, SBOM and In-Cluster Checks
One workflow that builds, signs keylessly with GitHub OIDC, attaches an SBOM and SLSA provenance, plus the Kyverno policy that refuses anything unsigned. Copy it, change three names, ship it.
GitLab CVE-2026-110264: A Second CVSS 10 RCE in Nine Days. Patch to 19.5.1
An unauthenticated regex-compiler RCE reaching back to GitLab 7.0, no workaround, and backports on older branches that fix only the critical bug. The exact version per branch and the commands to get there.
You might have missed
Evergreen posts worth revisiting.