We earn commissions when you shop through the links below, at no extra cost to you. Our guides and technical recommendations are written independently of these relationships: a commission never decides what we recommend, how we diagnose a problem or what we publish, and the content does not depend on it. Affiliate disclosure

Docker · Beginner · 10 min

Container exit codes 137, 139 and 143 explained

What exit code 143 (SIGTERM), 137 (SIGKILL, OOMKilled) and 139 mean in Docker and Kubernetes, who sent the signal, and the fix for each cause.

The exit code is the first evidence you get when a container stops, and it costs one command to read. This page maps each code to its usual cause, shows how to tell an out-of-memory kill from a stop by the runtime, and lists what to check next. Output was captured with Docker 29.1.3 on a WSL2 test machine.

A 40-second Short on exit code 137 (OOMKilled). It loads from YouTube only when you press play. Watch on YouTube ↗

The number is a clue, not a diagnosis

A container stops and docker ps -a shows Exited (137). The exit code is the first piece of evidence you have, and it costs one command to read. But the same number can have more than one cause, and some codes mean the container never really ran.

Linux exit statuses run from 0 to 255. A status above 128 means the process was killed by a signal, and the signal number is the code minus 128. That is how 137 becomes 128 + 9 (SIGKILL), 139 becomes 128 + 11 (SIGSEGV) and 143 becomes 128 + 15 (SIGTERM).

How a signal becomes an exit code137: SIGKILL (signal 9) then 128 + 9 = 137 then Who sent it? (oom=true: the kernel, memory limit. oom=false: docker stop after its grace period) 143: SIGTERM (signal 15) then 128 + 15 = 143 then A graceful stop (docker events shows who sent it) 139: SIGSEGV (signal 11) then 128 + 11 = 139 then A crash inside the process (for example a glibc binary on musl-based Alpine)137SIGKILLsignal 9128 + 9 = 137Who sent it?oom=true: the kernel, memorylimit. oom=false: docker stopafter its grace period143SIGTERMsignal 15128 + 15 = 143A graceful stopdocker events shows who sent it139SIGSEGVsignal 11128 + 11 = 139A crash inside theprocessfor example a glibc binary onmusl-based Alpine
Above 128, the signal number is the code minus 128. The same code can have different senders, so find out who sent the signal before you change anything.
Exit codeUsual meaningCheck first
0The main process finished normally. Not a crash: it was a short-lived command, or it moved itself into the backgroundWhat the main process is supposed to be
1 or another small numberThe application started and then failed: bad configuration, missing dependency, unhandled exceptionThe logs
125The Docker daemon could not run the container: a bad flag, or a name or port conflictThe error printed by docker run
126The command was found but could not be executedThe execute bit, or a directory used as the command
127The command was not foundThe path, and whether the image has a shell
137Killed by SIGKILLOOMKilled, see below
139Segmentation faultThe base image and native libraries
143Terminated by SIGTERM: something asked it to stopWho stopped it

Read it in one command

Do not guess from docker ps -a. Ask Docker for the exit code and the out-of-memory flag together:

# Exit code, out-of-memory flag and Docker error in one line
docker inspect --format 'exit={{.State.ExitCode}} oom={{.State.OOMKilled}} error={{.State.Error}}' CONTAINER
# Real output from a test machine (Docker 29.1.3)
exit=137 oom=true memlimit=33554432

Then read what the application said before it stopped:

# The last 100 lines the application wrote
docker logs --tail 100 CONTAINER

An empty log does not mean a quiet service. The process may have been killed before it wrote anything, or it may write to a file inside the container instead of stdout.

Terminal on a test machine: docker ps shows the container ob-oom exited with 137, docker inspect shows exit=137 oom=true memlimit=33554432, docker logs shows only the line worker: loading data, and the restart policy is no.
Real output from a WSL2 Ubuntu test machine (Docker 29.1.3). The container ran with a 32 MiB memory limit, was killed with exit 137 and oom=true, and logged only one line.

125, 126 and 127: it never really started

These are start-up failures, not application crashes.

  • 125: Docker itself could not run the container, for example because of a bad flag or a conflicting name or port. docker run reports it. It is not stored in the container.
  • 126: the command exists but cannot be executed. Usually the script lacks the execute bit, or the path is a directory.
  • 127: the command was not found. If the file exists and you still get no such file or directory, see exec ... no such file or directory. A common trap is shell form. CMD ./start.sh runs as /bin/sh -c ./start.sh, so an image without /bin/sh fails with 127. The exec form, CMD ["./start.sh"], runs the file directly.

Docker exit code 137 is two different failures

Exit code 137 means SIGKILL, and SIGKILL has more than one sender. The oom= field tells them apart.

oom=true: the kernel killed it. The container went past its memory limit. Raise the limit deliberately (--memory 1g, or mem_limit in Compose), reduce what the application uses, or fix a leak. Do not raise the limit past the memory the host actually has free, because that only moves the failure to the host.

oom=false: someone else sent SIGKILL. The most common cause is docker stop or an orchestrator giving up. They send SIGTERM first, wait for the grace period (10 seconds by default), and then send SIGKILL. If your application ignores SIGTERM, it ends as 137 every time. The fix is to handle SIGTERM and to run the application as PID 1 in exec form.

Same number, opposite fixes. Raising the memory limit does nothing for a container that ignores SIGTERM.

Exit code 143 and exit status 143 (SIGTERM) in Docker and Kubernetes

"Exited (143)", exit status 143 and exit code 143 all mean the same thing: the main process received SIGTERM (128 + 15) and ended. That is a request to stop, not a crash. If your process traps SIGTERM and exits with 0, you will see 0 instead; 143 appears when the default signal action ended the process, or when the runtime reports a signal death. What matters is who sent the signal. A CI job, a cleanup script, an orchestrator or a person may have stopped the container. Ask Docker:

# Who stopped or killed this container in the last 30 minutes
docker events --since 30m --filter container=CONTAINER --filter event=die --filter event=kill

docker stop sends SIGTERM, waits 10 seconds by default (-t or --stop-timeout changes it) and then sends SIGKILL. That is why 143 and 137 come as a pair: a process that shuts down inside the grace period leaves 143 (or 0 if it handles the signal), and a process that does not leaves 137 with oom=false.

If a container usually ends as 143 but sometimes as 137, the stop sometimes takes longer than the grace period. The application is slow to shut down, or it never sees the signal. Check these causes in order:

  1. Shell-form CMD or ENTRYPOINT. CMD ./app runs /bin/sh -c ./app, and the shell becomes PID 1 and may not forward SIGTERM to the app. Use the exec form (CMD ["./app"]), or exec ./app in a wrapper script, so the application is PID 1 and receives the signal.
  2. PID 1 signal handling. A process running as PID 1 gets no default signal actions, so without its own SIGTERM handler it ignores the signal until SIGKILL. Add a handler, or run the container with docker run --init (or init: true in Compose) to put a minimal init in front of it.
  3. Slow shutdown. Draining connections or flushing a queue can exceed 10 seconds. Raise it deliberately with docker stop -t 30, stop_grace_period: 30s in Compose, or STOPSIGNAL in the Dockerfile if the application expects a different signal.

Kubernetes exit code 143

In a Pod, Exit Code: 143 in kubectl describe pod (under Last State, Terminated) is the same SIGTERM. The kubelet sends SIGTERM when a Pod is deleted, a Deployment rolls out a new version, the Pod is scaled down or evicted, a node is drained, or a liveness or startup probe fails and the container is restarted. Then it waits terminationGracePeriodSeconds (30 seconds by default) and sends SIGKILL, which shows as 137.

# Last termination reason and exit code for every container in a Pod
kubectl get pod POD -o jsonpath='{range .status.containerStatuses[*]}{.name}{" "}{.lastState.terminated.reason}{" "}{.lastState.terminated.exitCode}{"\n"}{end}'
# Events show whether a probe, an eviction or a rollout caused the stop
kubectl describe pod POD | sed -n '/Events:/,$p'

A single 143 during a rollout or a drain is normal. A repeating 143 with Liveness probe failed events means the probe is killing a container that is not dead, so review the probe, not the application; see probes and resource limits. If the application needs more than 30 seconds to stop, raise terminationGracePeriodSeconds and, where needed, add a preStop hook. The hook runs inside the same grace period.

Exit code 139: a crash inside the process

139 is a segmentation fault. Look for a native library that does not match the base image, for example a binary built against glibc running on musl-based Alpine, and compare with a known-good image tag.

The same numbers in Kubernetes

Kubernetes reports the same exit codes, plus a reason. kubectl describe pod shows the last terminated state of each container:

Reason and exit codeMeaning
OOMKilled, 137The container exceeded its memory limit
137 without OOMKilledSIGKILL from elsewhere: a liveness kill after the grace period, a node-level out-of-memory event, or a manual kill
143Graceful stop. If it repeats, a liveness or startup probe may be killing the container

The detailed workflows are in the Kubernetes restarting Pod runbook and the guide to probes and resource limits.

kubectl exec and "command terminated with exit code 137". That line is not a Pod status. kubectl exec prints it when the command it ran inside the container ended with a non-zero code, and it passes the code on as its own exit status. On a kind cluster (kubectl 1.37, 6 November 2026), kubectl exec probe -- sh -c 'kill -9 $' printed command terminated with exit code 137 and exited 137, the same command with kill -15 printed command terminated with exit code 143 and exited 143, and exit 3 printed command terminated with exit code 3. The number follows the same 128 + signal rule as above, so 137 and 143 here mean the command was killed or asked to stop, not that the Pod crashed.

A 30-second routine

  1. Read the exit code and oom= with docker inspect.
  2. 125 to 127: fix how the container is started, not the application.
  3. 137: check oom=. True means memory. False means find who sent SIGKILL and whether the application handles SIGTERM.
  4. 143: find out who stopped it with docker events.
  5. Read the last 100 log lines before you change anything.
  6. Change one thing, run it again and read the exit code once more. A restart without a diagnosis only hides the evidence.

The full diagnosis workflow, including the safe fixes and the rollback, is in the guide Troubleshoot a Docker container that exits immediately. For reading logs safely, see Inspect Docker containers and read their logs.

Sources: Docker run reference: exit status, docker container inspect, signal(7) manual page, Kubernetes Pod lifecycle.

Verify the reading and roll back

This page only reads state, so there is nothing to roll back here. The fixes that change something (a memory limit, a SIGTERM handler, a restart policy) and the way to undo each of them are in Troubleshoot a Docker container that exits immediately.

Before you act on a reading, confirm it with a second signal:

  • For 137, oom=true together with a memory limit on the container means the kernel killed it. oom=false means someone sent SIGKILL: check whether docker stop or the orchestrator gave up after the grace period.
  • For 143, docker events shows who stopped the container.
  • After a change, run the container again and read exit= and oom= once more. The reading should differ; if it is the same number, the change did not touch the cause.

Official reference

docs.docker.com ↗

Technical steps are original explanations; consult the upstream documentation for version-specific details.

Behavior differs by distribution and tool version. Commands are examples for authorized systems; review output for secrets before sharing.

Found this useful?

Follow us on YouTube for video explainers, and find us on Facebook to keep up with what is new.