Skip to content
Latchkey

Container Memory Limit Exceeded in CI

A job running inside a container was killed because it crossed the container --memory limit. The cgroup OOM killer fires at the limit regardless of how much RAM the host has free.

What this error means

The container exits 137 / OOMKilled even though the host has free memory. Raising or removing the container --memory limit, or using a larger runner, clears it.

docker
$ docker inspect --format '{{.State.OOMKilled}}' job
true
##[error] The container exited with code 137 (OOMKilled).

Common causes

The container limit is below the job needs

A --memory/-m cap (or cgroup limit) smaller than peak usage triggers the cgroup OOM killer.

Multiple service containers sharing the limit

Service containers plus the job container together exceed the allotment.

How to fix it

Raise or remove the memory limit

Give the container enough headroom for peak usage.

docker
docker run -m 4g my-job
# in compose
services:
  job:
    mem_limit: 4g

Reduce usage or use a bigger runner

  1. Lower in-container parallelism and heap sizes.
  2. Split service containers across the available RAM.
  3. Move to a runner with more memory.

How to prevent it

  • Set container limits with real headroom over peak usage.
  • Right-size runners for containerized jobs.
  • Check OOMKilled when a container exits 137.

Related guides

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