Debug Docker containers, images, and infrastructure with a systematic four-phase methodology covering exit codes, OOM kills, build failures, networking, volumes, and permissions.
Ships in debug-and-refactor. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This guide provides a systematic approach to debugging Docker containers, images, networks, and volumes. Follow the four-phase methodology for efficient problem resolution.
Get immediate context about the issue.
# Check container status
docker ps -a
# View recent logs (last 50 lines)
docker logs --tail 50 <container>
# Check container exit code
docker inspect <container> --format='{{.State.ExitCode}}'
# Quick health check
docker inspect <container> --format='{{.State.Health.Status}}'
Deep dive into container logs and events.
# Follow logs in real-time
docker logs -f <container>
# View logs with timestamps
docker logs --timestamps <container>
# View logs since specific time
docker logs --since 30m <container>
# Check Docker daemon events
docker events --since 1h
# View system-wide logs
journalctl -u docker.service --since "1 hour ago"
Get hands-on access to the container environment.
# Open shell in running container
docker exec -it <container> /bin/sh
# or
docker exec -it <container> /bin/bash
# Run commands without shell
docker exec <container> cat /etc/hosts
docker exec <container> env
# Use docker debug for enhanced debugging (Docker Desktop 4.27+)
docker debug <container>
# Inspect container configuration
docker inspect <container>
# Check network configuration
docker network inspect <network>
Comprehensive investigation for complex issues.
# Monitor resource usage
docker stats <container>
# Check disk usage
docker system df -v
# Inspect image layers
docker history <image>
# Export container filesystem for analysis
docker export <container> -o container.tar
# View detailed container info
docker inspect <container> | jq '.'
| Exit Code | Meaning | Common Causes | Solution |
|---|---|---|---|
| 0 | Success | Normal termination | No action needed |
| 1 | General error | Application error, missing file | Check logs, verify files exist |
| 126 | Permission problem | Cannot execute command | Check file permissions, add execute bit |
| 127 | Command not found | Missing binary or PATH issue | Verify command exists in image |
| 137 | SIGKILL (OOM) | Out of memory | Increase memory limit, optimize app |
| 139 | SIGSEGV | Segmentation fault | Debug application code |
| 143 | SIGTERM | Graceful shutdown | Normal behavior during stop |
| 255 | Exit status out of range | Various | Check application error handling |
# Check if container was OOM killed
docker inspect <container> --format='{{.State.OOMKilled}}'
# View memory limits
docker inspect <container> --format='{{.HostConfig.Memory}}'
# Run with increased memory
docker run -m 2g --memory-swap 4g <image>
# Monitor memory in real-time
docker stats --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}"
# Build with verbose output
docker build --progress=plain -t <image> .
# Build without cache
docker build --no-cache -t <image> .
# Build specific stage for debugging
docker build --target <stage-name> -t <image> .
# Inspect build cache
docker builder prune --dry-run
# Debug failed layer by running from previous successful layer
docker run -it <last-successful-layer-id> /bin/sh
Common Build Issues:
COPY failed: file not found - Check paths are relative to build contextRUN failed - Check command syntax, ensure dependencies are installedPermission denied - Add chmod or run as appropriate user# List networks
docker network ls
# Inspect network
docker network inspect <network>
# Check container network settings
docker inspect <container> --format='{{json .NetworkSettings.Networks}}'
# Test connectivity between containers
docker exec <container1> ping <container2>
# Test DNS resolution
docker exec <container> nslookup <hostname>
# Check exposed ports
docker port <container>
# Debug with network tools
docker run --rm --network=<network> nicolaka/netshoot ping <target>
Common Network Issues:
lsof -i :<port> to find conflicting process# List volumes
docker volume ls
# Inspect volume
docker volume inspect <volume>
# Check mount points
docker inspect <container> --format='{{json .Mounts}}'
# Verify host path exists
ls -la /path/to/host/directory
# Check permissions inside container
docker exec <container> ls -la /mount/path
# Test with simple container
docker run --rm -v /host/path:/container/path alpine ls -la /container/path
Common Volume Issues:
Permission denied - Check UID/GID mapping, use :z or :Z for SELinux# Add user to docker group (Linux)
sudo usermod -aG docker $USER
newgrp docker
# Check Docker socket permissions
ls -la /var/run/docker.sock
# Run container as specific user
docker run --user $(id -u):$(id -g) <image>
# Fix file permissions in Dockerfile
RUN chown -R appuser:appuser /app
USER appuser
# Check what command is running
docker inspect <container> --format='{{.Config.Cmd}}'
docker inspect <container> --format='{{.Config.Entrypoint}}'
# Keep container running for debugging
docker run -d <image> tail -f /dev/null
# or
docker run -d <image> sleep infinity
# Override entrypoint for debugging
docker run -it --entrypoint /bin/sh <image>
# Check if process is foreground
# (Docker needs a foreground process to keep running)
Windows:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -Allwsl --installMac:
~/Library/Group\ Containers/group.com.docker/Linux:
sudo systemctl status dockerjournalctl -u docker.service# Container lifecycle
docker ps -a # List all containers
docker logs <container> # View logs
docker logs -f --tail 100 <container> # Follow last 100 lines
docker exec -it <container> sh # Interactive shell
docker inspect <container> # Full container details
docker top <container> # Running processes
# Images
docker images # List images
docker history <image> # Show image layers
docker inspect <image> # Image details
# System
docker system df # Disk usage
docker system events # Real-time events
docker system info # System-wide info
docker system prune # Clean up unused resources
# Network
docker network ls # List networks
docker network inspect <network> # Network details
# Volumes
docker volume ls # List volumes
docker volume inspect <volume> # Volume details
# Docker debug (Docker Desktop 4.27+)
docker debug <container> # Enhanced shell with tools
# Process inspection
docker exec <container> ps aux # List processes
docker exec <container> top # Interactive process viewer
# Network debugging
docker exec <container> netstat -tlnp # Open ports
docker exec <container> ss -tlnp # Socket statistics
docker exec <container> curl -v <url> # HTTP debugging
# File system
docker diff <container> # Changed files
docker cp <container>:/path ./local # Copy files out
docker cp ./local <container>:/path # Copy files in
# Resource monitoring
docker stats # Live resource usage
docker stats --no-stream # Single snapshot
For minimal images without debugging tools, use a sidecar approach:
# Use netshoot for network debugging
docker run -it --network container:<target> nicolaka/netshoot
# Use busybox for basic tools
docker run -it --pid container:<target> busybox
# Most common debugging sequence
docker ps -a # 1. Check status
docker logs --tail 100 -f <container> # 2. View logs
docker exec -it <container> sh # 3. Interactive shell
docker inspect <container> # 4. Full details
# Performance debugging
docker stats # Resource usage
docker system df # Disk usage
docker events # System events
# Network debugging
docker network ls # List networks
docker network inspect <network> # Network details
docker exec <container> ping <host> # Test connectivity
# Clean up
docker system prune -af # Remove all unused data
docker volume prune # Remove unused volumes
docker builder prune # Remove build cache
docker ps -adocker logs <container>docker inspect --format='{{.State.ExitCode}}'docker inspect --format='{{.State.OOMKilled}}'docker system dfWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/debug-and-refactor:debug:dockerfrom debug-and-refactor
npx claudepluginhub snakeo/claude-debug-and-refactor-skills-plugin --plugin debug-and-refactor45 skills in this plugin
/debug:angularDebug Angular applications systematically with expert-level diagnostic techniques. This skill provides comprehensive guidance for troubleshooting dependency injection errors, change detection issues (NG0100), RxJS subscription leaks, lazy loading failures, zone.js problems, and common Angular runtime errors. Includes structured four-phase debugging methodology, Angular DevTools usage, console debugging utilities (ng.probe), and performance profiling strategies for modern Angular applications./debug:djangoDebug Django web applications with systematic diagnostic approaches. This skill covers troubleshooting Django-specific errors including TemplateDoesNotExist, ImproperlyConfigured, IntegrityError, migration conflicts, CSRF failures, N+1 query problems, and circular imports. Includes Django Debug Toolbar setup, ORM query logging, pdb/ipdb usage, shell_plus debugging, and comprehensive logging configuration. Provides four-phase methodology for root cause analysis and regression prevention./debug:dotnetDebug ASP.NET Core and .NET applications with systematic diagnostic approaches. This skill covers troubleshooting dependency injection container errors, middleware pipeline issues, Entity Framework Core query problems, configuration binding failures, authentication/authorization issues, and startup failures. Includes Visual Studio and VS Code debugging, dotnet-trace, dotnet-dump, dotnet-counters tools, Serilog configuration, Application Insights integration, and four-phase debugging methodology.Other plugins' skills for the same job