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 exec -it <container> sh

Open a shell in a running container.

Debugging commands

Scenario Command What it tells you
Container crashes docker logs --tail 200 <ctr> Last N log lines before exit.
Container keeps restarting docker inspect <ctr> | grep -A5 State 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 why a container keeps restarting
# See last exit reason
docker inspect myapp --format '{{.State.ExitCode}} {{.State.Error}}'

# Read last 200 log lines
docker logs --tail 200 myapp

# Check restart policy
docker inspect myapp --format '{{.HostConfig.RestartPolicy}}'

Reclaim disk space
docker system df          # See what's using space
docker image prune -af    # Remove unused images
docker volume prune       # Remove unused volumes
docker system prune -af --volumes  # Nuclear option


Best practices

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

Related cheatsheets


Last reviewed: 2026-06-15

Join our Discord Server