Docker Exit Code 137: Why Your Container Was Killed and How to Fix It
Docker exit code 137 means the container got SIGKILL, usually from the out-of-memory killer. How to confirm OOMKilled, find the limit you hit, and fix it.
Exit code 137 means the main process in your container was killed with SIGKILL (signal 9), because 128 + 9 = 137. Most of the time the killer is the Linux out-of-memory (OOM) killer, which steps in when the container goes over its memory limit or the machine runs out of RAM. The other common cause is docker stop giving up after its grace period and sending SIGKILL itself. You can tell which one in a single command, and the fix depends on the answer.
Checked against the Docker docs (docker stop, resource constraints, Docker Desktop settings), the Docker Engine API spec and the bash manual in November 2026.
You'll usually meet it in one of these forms:
$ docker ps -a
CONTAINER ID IMAGE COMMAND STATUS
3f2a9c1d8e7b myapp "node server.js" Exited (137) 2 minutes ago
error Command failed with exit code 137.
process "/bin/sh -c npm ci" did not complete successfully: exit code: 137
The first is a running container that died. The second is Yarn reporting that a child process was killed. The third is BuildKit during docker build, when a RUN step was killed.
Why the number is 137
When a process is ended by a signal, the shell and Docker report the exit status as 128 plus the signal number. The bash manual puts it this way: "When a command terminates on a fatal signal N, bash uses the value of 128+N as the exit status." SIGKILL is signal 9, so 137. (Exit 143 is the same idea for SIGTERM, signal 15, which usually means the app shut down when asked.)
SIGKILL can't be caught or handled. The process gets no chance to log anything, flush buffers or print a stack trace, which is why a 137 so often comes with logs that just stop mid-line.
Step 1: was it the OOM killer?
Ask Docker directly. The Engine API records whether a process in the container was killed for running out of memory since it last started:
docker inspect --format '{{.State.OOMKilled}} {{.State.ExitCode}}' <container>
true 137: memory. Go to the next section.false 137: something else sentSIGKILL. Skip to "137 without OOMKilled" below.
To catch it as it happens, docker events --filter 'event=oom' prints an event whenever a container hits an out-of-memory condition. On a Linux host you can also look at the kernel log, where the OOM killer writes a line naming the process it killed:
sudo dmesg -T | grep -i -E 'out of memory|killed process'
# or on systemd hosts
journalctl -k | grep -i 'killed process'
A line starting with Memory cgroup out of memory means the container hit its own limit. A plain Out of memory line means the whole machine ran out. The Linux OOM Killer explains how the kernel picks its victim.
Step 2: find which limit you hit
There are three places the memory ceiling can come from, and it helps to know which one applies before changing anything.
| Where you run Docker | What sets the ceiling | How to check |
|---|---|---|
docker run / Compose with a limit |
-m / --memory, or mem_limit / deploy.resources.limits.memory in Compose |
docker inspect --format '{{.HostConfig.Memory}}' <container> (bytes, 0 = no limit) |
| No limit set, Linux host | The host's free RAM | free -h, docker stats |
| Docker Desktop (Mac, Windows, Linux) | The Docker VM's memory | Settings > VM resources > Advanced > Memory limit |
Docker's docs describe --memory as a hard limit, with a minimum of 6m. If you set it, the container can't go past it; the kernel kills a process inside instead.
Docker Desktop runs containers inside a VM, and per Docker's settings docs the VM's memory limit "defaults to 50% of your host's memory". Every container, and every docker build, shares that. In WSL 2 mode the memory limit isn't in Docker Desktop's settings at all: it's set for the WSL 2 VM in a .wslconfig file on the Windows side.
docker stats shows live usage against the limit, which is the quickest way to watch a container climb toward it:
docker stats --no-stream
Fixes for OOM kills, safest first
1. Check whether the usage is reasonable. A Node process that grows steadily until it's killed is often a leak, and raising the limit only delays the next 137. If memory climbs with traffic and drops back, the limit is just too low. How Container CPU and Memory Limits Actually Work covers what counts toward the limit (page cache included).
2. Make the runtime fit inside the container. Language runtimes don't always size themselves to the container. For Node.js, set the heap below the container limit so V8 garbage-collects harder before the kernel steps in:
docker run -m 1g -e NODE_OPTIONS=--max-old-space-size=768 myapp
Leave headroom: the heap isn't the only memory a Node process uses. If you then get "JavaScript heap out of memory" instead of 137, you've moved the failure somewhere you can see it; see JavaScript Heap Out of Memory.
3. Raise the limit. Increase --memory, or in Compose:
services:
app:
image: myapp
deploy:
resources:
limits:
memory: 1g
On Docker Desktop, raise the VM's memory limit in settings (or in .wslconfig for WSL 2) and restart Docker.
4. Add memory to the machine, or run fewer things on it. If there's no container limit and the kernel log says Out of memory, the host itself is full. Something else may be using the RAM; check with docker stats and free -h before buying a bigger server.
Avoid --oom-kill-disable as a fix. Docker's docs say to use it only on containers that also have a -m limit, because without one the host itself can run out of memory.
137 during docker build, npm install or yarn install
Package installs and frontend builds are memory-hungry, and during a build the limit that matters is usually the machine's (or Docker Desktop VM's) memory, not anything in your Dockerfile. The usual fixes:
- Raise Docker Desktop's memory limit, or build on a machine with more RAM.
- Close other containers while building. A running database and dev server eat into the same pool.
- Cap the Node heap in the step that runs out, for example
RUN NODE_OPTIONS=--max-old-space-size=2048 npm run build, so it fails with a readable error instead of a kill. - Build in CI on a larger runner and pull the finished image, rather than building on a small server.
137 without OOMKilled
If OOMKilled is false, something sent SIGKILL on purpose. The common sources:
docker stoptimed out. Per Docker's reference, the main process "will receiveSIGTERM, and after a grace period,SIGKILL", and the default grace period is 10 seconds for Linux containers. If your app ignoresSIGTERM, every stop ends in 137. A classic cause is an app running as PID 1 under a shell, which doesn't forward signals; PID 1 in Containers walks through the fix. You can also give slow shutdowns more time withdocker stop -t 30.docker kill, which sendsSIGKILLby default.- An orchestrator or host tool. Kubernetes, a deploy script, or a userspace OOM daemon like systemd-oomd can kill the container's processes directly. Check the host's journal for the time of the exit.
Quick checklist
docker inspect --format '{{.State.OOMKilled}} {{.State.ExitCode}}' <container>.- If
true: find the ceiling (container limit, host RAM, or Docker Desktop VM). - Watch usage with
docker statsand decide: leak or undersized limit? - Fit the runtime inside the limit, then raise the limit if needed.
- If
false: look at how the container was stopped, and make the app handleSIGTERM.
If the container is stuck in a loop of 137s, Docker Container Keeps Restarting shows how to get logs out of a crash loop.
On EasySpawn, your app, its database and Claude Code run on one persistent server, so they share its memory like any other machine and a heavy build can still squeeze a running app. What changes is that Claude Code works on the same server the app runs on, so it can run docker stats and docker inspect there instead of you copying output back and forth. See how it works or join the waitlist.
Related: The Linux OOM Killer: Why Your Process Was Killed · How Container CPU and Memory Limits Actually Work · Docker Container Keeps Restarting: How to Find Out Why · "JavaScript Heap Out of Memory": Why It Happens and How to Fix It
Keep reading
Docker "invalid reference format": What It Means and How to Fix It
Docker invalid reference format means the image name you passed isn't valid. The usual culprits: uppercase, spaces in paths, empty tags and stray characters.
Docker "error getting credentials": What It Means and How to Fix It
Docker error getting credentials means config.json points at a credential helper that is missing or failing. Fixes for Mac, Windows, WSL and Linux servers.