>_dockerfix
← back to error wikidocker

Container killed with exit code 137 (OOMKilled)

Container [name] exited with code 137
OOMKilled: true

What's happening

Exit code 137 means the container received SIGKILL (128 + 9). When the accompanying `docker inspect` output shows `"OOMKilled": true`, the kernel's cgroup memory controller killed the main process because the container hit its memory limit (set via `--memory` / `mem_limit`, or the cgroup default if none was set). This is not a crash in your application code — it's the host enforcing a hard ceiling. It's especially common with JVM, Node, or Python processes that don't know about the container's cgroup limit and try to allocate heap based on the host's total RAM instead.

Fix

1. Confirm it's really OOM: `docker inspect <container> --format '{{.State.OOMKilled}}'`
2. Check current limit: `docker inspect <container> --format '{{.HostConfig.Memory}}'` (bytes, 0 = no limit set at the container level, but the host may still enforce a default)
3. Raise the limit in compose:
```yaml
services:
  app:
    deploy:
      resources:
        limits:
          memory: 2g
```
4. If the process is a JVM, cap the heap explicitly instead of letting it guess: `-XX:MaxRAMPercentage=75.0` (Java 10+ respects cgroup limits, but older images or misconfigured `-Xmx` flags don't).
5. If memory keeps climbing instead of plateauing, it's a leak, not a sizing problem — check with `docker stats` over time before just raising the limit.
Got a different error? Paste it here for a free diagnosis.