Skip to content
Latchkey

Docker Build Exit Code 137 (OOM Killed) - Fix Out-of-Memory Builds

Exit code 137 is 128 + 9 - the process received SIGKILL. In CI that is almost always the out-of-memory killer terminating a build that exceeded the available memory.

What this error means

A RUN step or a container exits with code 137 and often the single word Killed. There is rarely a stack trace, because SIGKILL cannot be caught.

docker build output
#12 137.4 Killed
ERROR: process "/bin/sh -c npm run build" did not complete successfully: exit code: 137

Common causes

The build exceeded the memory limit

Webpack/bundler builds, large compiles, and test suites can spike past a runner’s memory ceiling. The cgroup OOM killer then terminates the heaviest process with SIGKILL.

A container memory limit is too low

If you pass --memory/-m or set a compose memory limit, exceeding it triggers the same kill at exit 137.

How to fix it

Give the build more memory

  1. Run the job on a larger runner with more RAM.
  2. Raise or remove an explicit container --memory limit if one is set.
  3. For Node, cap the heap below the container limit with NODE_OPTIONS=--max-old-space-size=4096.

Reduce peak memory

  1. Lower build parallelism (e.g. make -j2, Jest --maxWorkers=2).
  2. Split a monolithic build/test step into smaller steps.
  3. Avoid loading large datasets or source maps into memory during the build.

How to prevent it

  • Right-size runners for memory-heavy builds.
  • Set language heap limits relative to the runner memory.
  • Watch peak memory in CI so you catch growth before it OOMs.

Frequently asked questions

Is exit 137 always out of memory?
It means the process got SIGKILL. On memory-limited CI runners that is overwhelmingly the OOM killer, but it can also be an external watchdog or timeout --signal=KILL. Check the runner’s memory metrics or kernel log to confirm.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →