← All runbooks in Docker & Containers
medium riskservice affecting~15 min
Runbook: Application container exits immediately after start
1 · Prerequisites
Confirm every item is in place before any state change.
- docker exec available
- Container logs accessible
2 · Pre-checks
Read-only diagnostic commands. If any of these don't match expected output, stop and investigate further.
- · docker ps -a | grep CONTAINER
- · docker inspect CONTAINER --format "{{.State.ExitCode}}"
3 · Procedure
Execute each step in order. Verify the expected output of a step before moving to the next.
- 1Check the exit code (0=clean, 1=app error, 126=cant exec, 127=not found, 137=SIGKILL, 143=SIGTERM)
- 2Read the logs with docker logs CONTAINER --tail 100
- 3Inspect the image with docker run --rm --entrypoint /bin/sh myorg/myapp:1.0.0
- 4Verify resource limits are not exceeded
4 · Verification
Confirm the procedure actually fixed the problem.
- ✓Container stays running under normal load
- ✓docker ps shows Up X minutes
- ✓The application responds on its endpoints
5 · Rollback
If verification fails, undo the procedure in reverse order.
- ↶Re-deploy the previous image version
- ↶Restore from volume backup if state was lost
- ↶Page the on-call engineer for the service
6 · Escalation
When the runbook isn't enough, contact:
- · Page the on-call engineer if diagnosis takes more than 15 minutes
- · Capture full logs and inspect output before changing anything
Symptoms
docker psshows the container inExited (1)state.docker logs CONTAINERshows an error message.- Health check (if configured) reports unhealthy.
- The container keeps restarting if
restart: alwaysis set.
Diagnosis
- Check the exit code.
docker ps -a | grep CONTAINERdocker inspect CONTAINER --format "{{.State.ExitCode}}"- Common exit codes: 0 (clean exit), 1 (app error), 126 (can't execute), 127 (not found), 137 (SIGKILL), 143 (SIGTERM).
- Read the logs.
docker logs CONTAINER --tail 100- Look for stack traces, missing dependencies, configuration errors.
- Check the entrypoint.
docker inspect CONTAINER --format "{{.Config.Entrypoint}} {{.Config.Cmd}}"- Confirm the entrypoint exists in the image and is executable.
- Inspect the image.
docker run --rm --entrypoint /bin/sh myorg/myapp:1.0.0- Then inside the container:
ls -la /app/(or wherever the entrypoint expects)/app/entrypoint.sh --help(test the entrypoint manually)- Check resource limits.
docker inspect CONTAINER --format "{{.HostConfig.Memory}}"- OOM-killed containers exit with 137. Increase the limit if needed.
Resolution
Based on the diagnosis:
- Application error (exit 1). Fix the application bug. Re-deploy.
- Missing binary (exit 126/127). The image is broken; rebuild it.
- OOM killed (exit 137). Increase memory limit or fix the leak.
- Killed by SIGTERM (exit 143). Usually a startup-timeout exceeded.
Verification
- The container starts and stays running.
docker psshowsUp X minutes. - The healthcheck passes.
docker inspectshowsStatus: healthy. - The application responds.
docker exec CONTAINER curl localhost:8080/healthreturns 200.
Escalation
If the container still fails after these steps:
- Capture the full log output.
- Capture the exit code and any OOMKilled flag.
- Page the on-call engineer for the affected service.
- Do not restart the container repeatedly; that wastes evidence.
Prevention
- Add a healthcheck that exercises the application’s actual
functionality, not just
curl /. - Set sensible
restart: on-failure:5to limit crash loops. - Capture the entrypoint’s exit code in a wrapper script that logs to stderr before exiting.