debug:docker
Debug Docker containers, images, and infrastructure with systematic diagnostic techniques. This skill provides comprehensive guidance for troubleshooting container exit codes, OOM kills, image build failures, networking issues, volume mount problems, and permission errors. Covers four-phase debugging methodology from quick assessment to deep analysis, essential Docker commands, debug container techniques for minimal images, and platform-specific troubleshooting for Windows, Mac, and Linux.
What this skill does
# Docker Debugging Guide
This guide provides a systematic approach to debugging Docker containers, images, networks, and volumes. Follow the four-phase methodology for efficient problem resolution.
## The Four Phases of Docker Debugging
### Phase 1: Quick Assessment (30 seconds)
Get immediate context about the issue.
```bash
# 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}}'
```
### Phase 2: Log Analysis (2-5 minutes)
Deep dive into container logs and events.
```bash
# 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"
```
### Phase 3: Interactive Investigation (5-15 minutes)
Get hands-on access to the container environment.
```bash
# 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>
```
### Phase 4: Deep Analysis (15+ minutes)
Comprehensive investigation for complex issues.
```bash
# 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 '.'
```
---
## Common Error Patterns and Solutions
### Exit Codes
| 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 |
### OOM Killed Containers (Exit Code 137)
```bash
# 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}}"
```
### Image Build Failures
```bash
# 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 context
- `RUN failed` - Check command syntax, ensure dependencies are installed
- `Permission denied` - Add `chmod` or run as appropriate user
### Networking Issues
```bash
# 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:**
- Containers on different networks cannot communicate
- Port already in use: `lsof -i :<port>` to find conflicting process
- DNS resolution fails: Check Docker DNS settings
### Volume Mount Problems
```bash
# 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
- Path not found - Ensure host path exists before mounting
- Windows paths - Use forward slashes or escaped backslashes
### Permission Denied Errors
```bash
# 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
```
### Container Exits Immediately
```bash
# 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)
```
### Docker Desktop Won't Start
**Windows:**
- Enable Hyper-V: `Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All`
- Enable WSL2: `wsl --install`
- Check virtualization in BIOS (VT-x/AMD-V)
- Temporarily disable antivirus
**Mac:**
- Check available disk space
- Reset Docker Desktop: Delete `~/Library/Group\ Containers/group.com.docker/`
- Reinstall Docker Desktop
**Linux:**
- Check Docker daemon: `sudo systemctl status docker`
- View daemon logs: `journalctl -u docker.service`
---
## Debugging Tools Reference
### Essential Commands
```bash
# 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
```
### Advanced Debugging
```bash
# 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 exRelated in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.