Fix a Docker container that will not start
We'll check docker logs, docker inspect, and docker run—to isolate exit codes, image issues, and resource limits—or tell you when to escalate.
What you'll need
- Docker installed and running
- Container name or ID (or image name to reproduce)
- Access to run docker logs, docker inspect, docker run
Step-by-step diagnostic
Quick triage — pick your path
Get started
Choose the option that matches what you see. You can jump straight to that section.
- Follow this guide Work through the full container start procedure.
- Check logs and exit code You want to see why the container exited.
- Reproduce with docker run You want to run the container and capture errors.
- Check image and entrypoint The container exits immediately with code 127 or 126.
- When to get help Logs and inspect do not reveal the cause.
Show full guide
Steps
Goal: Find why the container exits, then fix the entrypoint, image, resources, or config.
- Run
docker logs container-nameto see the last output. - Good: You see an error. Proceed to Check logs and exit code.
- Bad: Logs empty—run docker inspect for exit code.
Check logs and exit code
Goal: See why the container exited.
- Run
docker logs container-name. Look for permission denied, no such file, address already in use, or app errors. - Run
docker inspect container-name --format "{{.State.ExitCode}} {{.State.Error}}". Exit 0: clean exit. 137: OOM. 139: segfault. 127: command not found. - Good: You have the exit code and logs. Proceed to Reproduce with docker run or Check image and entrypoint.
- Bad: Container not found—check name or run docker run to create.
Reproduce with docker run
Goal: Run the container and capture errors in real time.
- Run
docker run --rm -it image-namewith the same env, volumes, and ports from docker inspect. - When it exits immediately, you see the error before the prompt returns.
- Add
--entrypoint /bin/shto bypass the entrypoint and debug inside the container. - Good: You reproduce the failure and see the error.
- Bad: Container runs—issue may be specific to the original run config.
Check image and entrypoint
Goal: Confirm the entrypoint and exit code make sense.
- Run
docker inspect image-name --format "{{.Config.Entrypoint}} {{.Config.Cmd}}". Wrong or missing entrypoint causes exit 0 or 127. - When the image is wrong architecture (amd64 on arm64), you may see “exec format error”. Pull the correct image.
- Good: Entrypoint and image are valid. Proceed to fix env, volumes, or resources.
- Bad: Entrypoint wrong or image incompatible—fix Dockerfile or use correct image.
Fix entrypoint or command
Goal: Override the entrypoint or add env when the app needs it.
- Run
docker run --entrypoint /bin/sh image-name -c "your command"to test. - Add
-e VAR=valuefor required env vars. Add-v /host/path:/container/pathfor config files. - Update the Dockerfile or run command with the correct entrypoint and env.
- Good: Container runs and stays up.
- Bad: Still exits—check resource limits or image.
Fix resource limits or image
Goal: Address OOM or wrong image.
- When exit code is 137 (OOM), run
docker run -m 512m image-nameor fix the app. - When the image is wrong architecture, pull the correct tag. When the base has a bug, update the Dockerfile.
- Good: Container starts and runs.
- Bad: Contact support with logs and inspect output.
When to get help
Contact support or the image maintainer when:
- Logs and inspect do not reveal the cause.
- The image is from a vendor and fails consistently.
- You suspect a Docker or host bug.
Provide container name, image, docker logs output, and docker inspect State and HostConfig. Check Docker and host logs for errors.
Verification
docker psshows the container in Up state (not Exited).docker logs container-nameshows the app running (no immediate exit).- No restart loop—the container stays up for the expected duration.
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Check logs Run docker logs to see stdout/stderr before exit.
- Check exit code and state Run docker inspect for ExitCode and Error.
- Reproduce with docker run Run the image with same flags to capture errors.
- Check entrypoint and image Verify entrypoint, cmd, and image architecture.
- Fix entrypoint, env, or resources Override entrypoint, add env, increase memory, or fix image.
- Contact support Provide logs, inspect output, and image name.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- Container name or ID
- Output of docker logs container-name
- Output of docker inspect container-name (State, HostConfig)
- Image name and tag
- docker run command used (with flags)
- Steps already tried
Does the container exit immediately or stay in a restart loop?
docker ps -a shows Exited. docker logs shows the last output.
You can change your answer later.
Container is running
What does docker logs show?
Logs show stdout/stderr from the last run.
You can change your answer later.
Check docker inspect for exit code
Is exit code 0 or non-zero?
0 = clean exit. Non-zero = crash or error.
You can change your answer later.
Check entrypoint and cmd
Is it OOM (exit 137) or other crash?
137 = OOM kill. 139 = segfault. 127 = command not found.
Reviewed by Blackbox Atlas
Frequently asked questions
- Why would a Docker container not start?
- Exit code 0: app or entrypoint exited. Non-zero: crash, missing dependency, or OOM. Image pull failure, wrong entrypoint, missing env vars, or resource limits can also prevent start.
- How do I see why a container exited?
- Run docker logs container-name for stdout/stderr. Run docker inspect container-name and check State.ExitCode and State.Error. Run docker run with the same image and flags to reproduce.
- When should I rebuild the image or contact support?
- Rebuild when the entrypoint or base image is wrong. Contact support when you have logs and inspect output but the cause is unclear, or when the image is from a vendor and fails consistently.
Rate this guide
Was this helpful?
Thanks for your feedback.