Docker Container Crash
Diagnose containers that crash or restart.
A Docker container that crashes or restarts in a loop is frustrating to debug. The container disappears before you can see what's happening. Here's how to investigate.
Symptoms
- Container that restarts in a loop (restart loop)
- "Exited" status with an error code
- Application inaccessible after deployment
- Logs that suddenly stop
Common Causes
- Code error: An unhandled exception at startup kills the main process.
- Missing configuration: Environment variable or config file missing.
- Unavailable dependency: The DB or external service isn't ready at startup.
Diagnostic Steps
- Check logs with docker logs [container]
- Inspect state with docker inspect [container]
- Examine the exit code
- Run in interactive mode to debug
Automate with MoniTao
MoniTao detects when your containers aren't working:
- HTTP monitoring of the containerized application
- Immediate alerts if the service stops responding
- Heartbeat for job containers
Best Practices
- Use HEALTHCHECK in your Dockerfile
- Implement wait-for-it for dependencies
- Configure appropriate restart policies
- Centralize logs (ELK, CloudWatch)
FAQ
What does exit code 137 mean?
The container was killed by OOM Killer (out of memory).
Exit code 1 vs exit code 0?
0 = success, 1 = general error, 137 = OOM, 143 = SIGTERM.
How to debug without the container disappearing?
Change CMD to sleep infinity and exec into it.
Does MoniTao monitor Docker directly?
No, but it monitors services exposed by your containers.
Useful Links
Ready to Sleep Soundly?
Start free, no credit card required.