Join our Discord Server

Docker Troubleshooting Cheatsheet

← All cheatsheets
TroubleshootingIntermediate

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

docker logs --tail 100 -f <container>

Tail the last 100 log lines and follow.

docker inspect <container>

Get full low-level JSON details.

docker stats

Live CPU, memory, network I/O per container.

Debugging commands

ScenarioCommandWhat it tells you
Container crashesdocker logs --tail 200 <ctr>Last N log lines before exit.
Container restartingdocker inspect <ctr>Exit code, error, restart count.
Disk fulldocker system dfSpace used by images, containers, volumes, cache.
Network issuesdocker network inspect <net>Connected containers, IPs, DNS settings.
High CPUdocker statsLive CPU, memory, network I/O per container.
Port conflictdocker ps --filter publish=8080Which container is using port 8080.
Image too largedocker 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 myapp
Reclaim disk space
docker system df
docker image prune -af
docker volume prune
docker system prune -af --volumes

Best practices

  • Check docker events for a real-time stream of Docker daemon events.
  • Use docker inspect liberally — it reveals everything about a container configuration.
  • Always set a --log-driver in production so logs persist after container removal.

Related cheatsheets


Last reviewed: 2026-06-15
Join our Discord Server