← All cheatsheets
Docker Troubleshooting Cheatsheet
Debug containers, inspect logs, trace networking issues, and fix common Docker problems.
What it is
This cheatsheet covers the most common Docker debugging workflows: inspecting logs, network tracing, container inspection, and disk management.
Quick start
Tail the last 100 log lines and follow.
Get full low-level JSON details.
Live CPU, memory, network I/O per container.
Debugging commands
| Scenario | Command | What it tells you |
|---|---|---|
| Container crashes | docker logs --tail 200 <ctr> | Last N log lines before exit. |
| Container restarting | docker inspect <ctr> | Exit code, error, restart count. |
| Disk full | docker system df | Space used by images, containers, volumes, cache. |
| Network issues | docker network inspect <net> | Connected containers, IPs, DNS settings. |
| High CPU | docker stats | Live CPU, memory, network I/O per container. |
| Port conflict | docker ps --filter publish=8080 | Which container is using port 8080. |
| Image too large | docker history <image> | Layer-by-layer size breakdown. |
Real-world examples
Debug a container that keeps restarting
# See last exit reason
docker inspect myapp --format '{{.State.ExitCode}} {{.State.Error}}'
# Read last 200 log lines
docker logs --tail 200 myappReclaim disk space
docker system df
docker image prune -af
docker volume prune
docker system prune -af --volumesBest practices
- Check
docker eventsfor a real-time stream of Docker daemon events. - Use
docker inspectliberally — it reveals everything about a container configuration. - Always set a
--log-driverin production so logs persist after container removal.
Related cheatsheets
Last reviewed: 2026-06-15