Docker Container Not Starting — How to Fix
A Docker container that won't start is one of the most frustrating issues in containerized development. This guide covers every common cause and its fix.
What You'll Learn
You'll learn how to diagnose why a Docker container fails to start and apply the correct fix in under two minutes.
Why It Matters
A non-starting container blocks your entire development or deployment pipeline, wasting time and delaying releases.
Real-World Use
A staging server goes down after a deploy because the container exits immediately — you need to identify and fix the root cause fast.
Step 1 — Check Container Logs
Always start with logs:
docker logs <container-name>
Expected output: Error messages showing exactly why the container stopped.
If the container is not running, use:
docker logs --tail 50 <container-name>
Step 2 — Check Container Status
docker ps -a | grep <container-name>
Expected output: Shows the container with status like Exited (1) 2 minutes ago. The exit code tells you what happened.
| Exit Code | Meaning | Common Cause |
|---|---|---|
| 0 | Clean exit | App finished, no long-running process |
| 1 | General error | App crashed on startup |
| 137 | SIGKILL | OOM killed by kernel |
| 139 | SIGSEGV | Segmentation fault |
| 143 | SIGTERM | Graceful shutdown |
Step 3 — Common Fixes
Container Exits Immediately (Exit 0)
Your app starts and finishes without staying alive. Add a foreground process:
CMD ["tail", "-f", "/dev/null"]
Or run interactively:
docker run -it <image> /bin/bash
Expected behavior: Container stays running with an active shell.
Port Already in Use (Exit 125)
Error response from daemon: driver failed programming external connectivity
Find and stop the conflicting container:
docker ps | grep <port>
docker stop <conflicting-container>
Or use a different host port:
docker run -p 8081:80 <image>
OOM Killed (Exit 137)
The container ran out of memory. Increase the limit:
docker run -m 512m <image>
Or check for memory leaks in your application.
Volume Mount Issues
docker run -v /host/path:/container/path <image>
Verify the host path exists:
ls /host/path
Expected behavior: If the path doesn't exist, Docker creates an empty directory owned by root, which may cause permission errors inside the container.
Entrypoint or CMD Error
Override the entrypoint to debug:
docker run --entrypoint /bin/bash <image>
Then manually start your application to see the exact error.
Prevention Tips
- Always run
docker build --no-cacheafter changing Dockerfiles - Pin base image versions, never use
latest - Add health checks to your Dockerfile
- Use
<a href="/devops/docker-compose/">docker compose</a> upfor multi-container debugging
Quick Reference
| Symptom | Command | Fix |
|---|---|---|
| Container exits immediately | docker logs <name> |
Add foreground process |
| Port conflict | docker ps \| grep <port> |
Change host port |
| OOM killed | dmesg \| grep oom |
Increase memory limit |
| Unknown error | docker run --entrypoint sh <image> |
Debug interactively |
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro