Incident Guide · Docker

Container keeps restarting? Check the exit code first

Most engineers spend 20 minutes looking in the wrong place before they even check what actually killed the container. The exit code tells you almost everything you need to know.

Check this first

docker inspect <container> --format='{{.State.ExitCode}}'

This single number narrows the problem before you read a single log line.

What each exit code means

CodeMeaning
1Application error — check app logs for an unhandled exception
137OOMKilled — container exceeded its memory limit
139Segmentation fault
143SIGTERM — the orchestrator deliberately terminated the container
127Command not found inside the image

Exit 137: memory, not mystery

If you see Exit 137, there's usually one conclusion: the container ran out of memory. Kubernetes or Docker killed it, and it will keep restarting until the underlying memory issue is fixed — not until you just add more memory.

1Genuine memory leak
Memory usage climbs steadily over hours, not a sudden spike. Look for unclosed connections, growing in-memory caches, or unbounded queues.
2Limit set too low for the real workload
Usage was always near the ceiling. Check historical memory graphs, not just the moment of the crash, before deciding this is the cause.
3Traffic or batch-size spike
A sudden jump in memory right before the kill. Check what changed — a deploy, a cron job, or an upstream traffic burst.

Exit 1: start here, not the config

A different problem entirely — the application crashed during startup, often a missing environment variable or a config error.

docker logs <container> 2>&1 | head -20

The root cause is almost always visible in the first 20 lines.

What not to do

Raising the memory limit on Exit 137 without checking which cause applies just delays the same failure at a higher ceiling. It's the first thing most people try and often the wrong fix.

Paste the exit code and logs, get the real cause

OperatorMesh reads your actual container logs and exit signal, then ranks the likely cause with a confidence score — instead of working through this list by hand.

⚡ Try it free →