A container that stops right after docker run, or loops in "Restarting", almost always has a main process that exits or crashes. The exit code tells you why.
| Code | Meaning | Usual cause |
|---|---|---|
0 | Finished successfully | Main process is not long-running (a script, or a service started in the background) |
1 | Application error | Bad config, missing env var, cannot reach DB: read the logs |
126 | Command not executable | Missing execute permission on the entrypoint script |
127 | Command not found | Typo in CMD, or binary missing from a slim image |
137 | Killed (SIGKILL) | Out of memory (OOMKilled: true) or docker kill |
139 | Segmentation fault | Native crash, often wrong CPU architecture |
143 | Terminated (SIGTERM) | Normal docker stop |
nginx -g "daemon off;", not a service that forks and returns. For a test container use sleep infinity-e variables or --env-filecondition: service_healthyentrypoint.sh give no such file or directory: convert with dos2unix--memory, or tune the app heap (e.g. -XX:MaxRAMPercentage=75 for Java)A restart policy hides crashes by restarting forever. While debugging, run without --restart (or restart: "no" in Compose) so the failure stays visible.