Exit codes

When a container stops, docker ps -a shows the exit code of its main process. The number tells why it stopped: 0 it finished, 1 the app failed, 137 it was killed, 143 it was asked to stop.

How it works

Codes above 128 mean a signal: 128 + 9 (SIGKILL) = 137, 128 + 15 (SIGTERM) = 143. 137 comes from docker kill, from docker stop after its grace period, or from the kernel's OOM killer, in which case docker inspect shows OOMKilled: true. 126 and 127 mean the command could not run or was not found.

What breaks

Exited (0) right after start is not a success for a server: its main process simply had nothing left to do. Read the code first, then docker logs, before changing anything.

In a terminal

docker ps -a
docker inspect -f '{{.State.ExitCode}} {{.State.OOMKilled}}' api
docker logs --tail 20 api

See it break, then fix it

Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.