In short: Check docker inspect: if State.OOMKilled is true, memory killed it. Give the container a limit with headroom over what docker stats shows at its busiest, and keep the sum of all limits below the machine's RAM. If the agent needs more than the host can spare, as NanoClaw (one container per session, about 4 GB recommended) can on a small board, buy memory rather than tuning.
| Exit code 137 | 128 + 9: the process ended on SIGKILL (Bash convention) |
|---|---|
| Confirm OOM | docker inspect, State.OOMKilled: true |
| Live usage | docker stats, MEM USAGE / LIMIT |
| Hard limit | --memory (-m), minimum 6m |
| Swap | --memory-swap is memory plus swap; equal to --memory means no swap |
| Containers | not given a protected OOM priority, unlike the Docker daemon |
Why 137 means killed
Docker's pages do not explain the number 137; it comes from the shell convention for processes ended by a signal. The Bash manual: "When a command terminates on a fatal signal whose number is N, Bash uses the value 128+N as the exit status." SIGKILL is signal 9 on x86 and Arm (signal(7)), and 128 + 9 = 137. SIGKILL "cannot be caught, blocked, or ignored", which is why the agent writes no error of its own: it simply stops.
137 alone does not prove memory. docker stop sends SIGTERM and, if the container "does not exit after the timeout elapses, it's forcibly killed with a SIGKILL signal" (10 seconds by default on Linux): an agent slow to shut down ends with 137 too. The memory case is the one Docker flags.
Confirm it was memory
docker inspect --format '{{.State.OOMKilled}} {{.State.ExitCode}}' <container>The Docker Engine API defines OOMKilled as "Whether a process within this container has been killed because it ran out of memory since the container was last started", and ExitCode as "The last exit code of this container". true 137 is the answer you are looking for.
To catch the next one as it happens, docker events lists oom among its container events. To see how close a container runs to its limit:
docker stats --no-streamIts MEM USAGE / LIMIT column is "the total memory the container is using, and the total amount of memory it is allowed to use". On Linux the CLI's figure leaves out the page cache.
Container limit or whole host: two different kills
With --memory set, the cap applies to that container: Docker's docs say that by default, when an out-of-memory error occurs, "the kernel kills processes in a container." Without a limit, a container can use the machine's memory until the kernel runs short. Docker's resource docs describe what happens then: the kernel "starts killing processes to free up memory", and "Any process is subject to killing, including Docker and other important applications." Docker lowers the daemon's OOM priority, but "The OOM priority on containers isn't adjusted", so an agent container is a likely target.
A limit does not make the agent fit. What it changes is where the failure lands: on the container you capped, rather than on whatever process the kernel picks when the whole host runs short, which could be the SSH server or the database.
Set a limit that fits
The flags, as Docker documents them:
| Flag | What it does |
|---|---|
-m, --memory | "The maximum amount of memory the container can use." Minimum 6m. |
--memory-swap | memory plus swap in total; only meaningful with --memory |
--memory-swap equal to --memory | no swap for the container |
--memory-swap unset | as much swap as the memory setting, if the host has swap (300m becomes 600m in total) |
--memory-swap=-1 | unlimited swap, up to what the host has |
--memory-reservation | a soft limit below --memory, applied under contention; not a guarantee |
--oom-kill-disable | only with --memory set, per Docker's docs |
For example, a hard cap of 2 GB with no extra swap:
docker run -m 2g --memory-swap 2g <image>In Compose, the deploy specification sets the same cap under deploy.resources.limits.memory. Pick the number from docker stats at the agent's busiest moment, plus headroom, and add up every container's cap: the total has to stay below the RAM, with room for the system.
For a Node.js agent in a container, the heap cap is a second limit inside the first. OpenClaw's docs say to pass --max-old-space-size or set NODE_OPTIONS in the container's launch environment, and that its Docker image defaults to MALLOC_ARENA_MAX=2 "to reduce glibc malloc arena fragmentation". A heap cap above the container's limit lets Node grow until the kernel kills it; the heap error itself is covered on JavaScript heap out of memory.
Containers per agent: why NanoClaw needs room
Some agents run one container; NanoClaw runs many. Its README: each agent group gets "its own memory, its own containers (one per session)", and "A single Node host orchestrates per-session agent containers." The agent image is built on node:22.23.4-slim with Chromium for browser automation. NanoClaw asks for "About 4 GB of RAM", and its installer warns below 3,700 MB.
Several sessions at once means several of those containers at once, so the memory a NanoClaw host needs grows with how many conversations run in parallel (our reading of that design, not a figure NanoClaw publishes). 4 GB is the floor it states, not a target for a busy host. The machine we point to for it is on NanoClaw on a Mac mini (Mac mini M4 on Amazon); on a mini PC, a 32 GB SO-DIMM kit (DDR5 SO-DIMM 32 GB on Amazon) adds headroom if the slots take it. Our sizing estimates per agent are on how much RAM an agent needs.
What to buy
- DDR5 SO-DIMM 32 GB kit: headroom for many containers on a mini PC with DDR5 slots; check the machine's type first.
- DDR4 SO-DIMM 32 GB kit: the same for older mini PCs with DDR4.
- Mac mini M4: memory is fixed at order: take more than NanoClaw's 4 GB floor for parallel sessions.
Shop links go through /go/ and open Amazon (amazon.fr in the EU and Switzerland, amazon.com elsewhere). As an Amazon Associate we earn from qualifying purchases. Your price does not change and no brand pays for a place on this page (disclosure). We write no price down: it moves, the shop shows today's.
Questions
What does Docker exit code 137 mean?
How do I check if a container was OOM killed?
Exit code 137 but OOMKilled is false. What else?
Should I use --oom-kill-disable?
Does adding swap stop exit code 137?
Sources
- Docker docs, resource constraints (memory), read on 21 November 2026.
- Docker Engine API reference, ContainerState (OOMKilled, ExitCode), v1.57, read on 21 November 2026.
- Docker docs, docker container stop, read on 21 November 2026.
- Docker docs, docker container stats, read on 21 November 2026.
- Docker docs, docker system events, read on 21 November 2026.
- Docker docs, Compose deploy specification, read on 21 November 2026.
- GNU Bash manual, exit status, read on 21 November 2026.
- Linux man-pages, signal(7), read on 21 November 2026.
- OpenClaw docs, Gateway service and process troubleshooting, read on 21 November 2026.
- NanoClaw README, read on 21 November 2026.
- NanoClaw docs, installation, read on 21 November 2026.