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: 137Common 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
- Run the job on a larger runner with more RAM.
- Raise or remove an explicit container
--memorylimit if one is set. - For Node, cap the heap below the container limit with
NODE_OPTIONS=--max-old-space-size=4096.
Reduce peak memory
- Lower build parallelism (e.g.
make -j2, Jest--maxWorkers=2). - Split a monolithic build/test step into smaller steps.
- 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
Docker "no space left on device" - Causes and FixesWhy Docker builds fail with "no space left on device" in CI, and how to reclaim space, prune layers, and stop…
Exit Code 137 Explained: SIGKILL and the OOM Killer in CIWhat exit code 137 means in CI: the process received SIGKILL, almost always from the out-of-memory killer. Ho…
Self-Healing CI: Recovering from OOM-Killed Jobs (Exit 137)Out-of-memory kills (exit 137) are mechanical, not code bugs. See the manual fix and how self-healing CI auto…
Node.js "JavaScript heap out of memory" in CI - Fix FATAL Heap ErrorsFix "FATAL ERROR: Reached heap limit - JavaScript heap out of memory" in CI builds by raising the V8 heap lim…