Scenario
In production environments, Docker containers may suddenly stop, fail to start, or exhibit erratic behavior. Common scenarios include: containers repeatedly restarting (CrashLoopBackOff), Out-of-Memory (OOM) kills due to memory leaks, disk space exhaustion, and volume permission errors.
Symptoms
- Container status shows
ExitedorCrashLoopBackOff(in Kubernetes) - Host logs contain "out of memory" or "cannot allocate memory"
docker psoutput missing expected containers- Application unresponsive but container appears running (zombie process)
Diagnosis
1. Check Container State
docker ps -a | grep <container-name>
docker inspect <container-id> --format '{{.State.Status}}'
2. View Logs
docker logs --tail 100 <container-id>
docker logs --since 5m <container-id>
3. Monitor Resource Usage
docker stats --no-stream <container-id>
4. Examine Host Resources
free -h
df -h
top -bn1 | head -20
5. Inspect Docker Daemon
journalctl -u docker --since "5 minutes ago"
Commands
- Restart container:
docker restart <container-id>(temporary relief) - Remove and recreate:
docker rm -f <container-id>then re-run - Debug running container:
docker exec -it <container-id> /bin/sh(if still running) - Export filesystem:
docker export <container-id> > container.tar
Risk Controls
- Before executing
docker restartin production, ensure health checks are configured with properstop_grace_period. - Using
docker rm -fkills processes immediately and may lose unsaved data. Preferdocker stopto allow signal handling. - In Kubernetes, avoid direct docker commands on Pod containers; use
kubectlto prevent orchestration state mismatch.
Rollback
- If issue stems from an image update, revert to previous stable tag:
bash docker pull <image>:<previous-tag> docker-compose up -d (if using Compose) - In Kubernetes, use
kubectl rollout undo deployment/<name>to revert to the previous revision.
Verification
- Confirm container state
Up:docker psorkubectl get pods - Application health endpoint returns 200:
curl http://localhost:<port>/health - Resource usage stable:
docker statsshows memory/CPU within expected limits - No errors in recent logs:
docker logs --tail 50 <container-id>shows no anomalies
When to Submit an OpsGlobal Ticket
Submit a ticket for our SRE team when:
- Container still unrecoverable after following the above steps
- Docker storage driver (e.g., overlay2) corruption requiring filesystem repair
- Multiple hosts experience Docker daemon failures simultaneously
- Need analysis of Docker daemon coredump or debug mode (-D) logs
- Must evaluate and adjust Docker runtime parameters (e.g., --default-ulimit or --oom-score-adjust)
Use cases
Useful for teams handling DevOps issues and needing a clear troubleshooting and delivery workflow.
Problem background
Dive into real-world Docker runtime issues, from container crashes to resource exhaustion, with diagnostic commands, risk controls, and escalation paths for OpsGlobal support.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.