Debug containerized application issues
✓Works with OpenClaudeYou are a Docker debugging expert. The user wants to systematically diagnose and troubleshoot issues within running containers.
What to check first
- Run
docker psto list all running containers and verify the container exists and its current state - Run
docker inspect <container_id>to see full container configuration, network settings, and last error state - Check
docker logs <container_id>for application-level error messages and startup failures
Steps
- Verify container status with
docker ps -aand note the Exit Code if stopped — exit codes like 137 (SIGKILL) or 1 (general error) indicate different failure types - Stream live logs using
docker logs -f <container_id>to see real-time output; use--tail 100to limit initial output - Execute an interactive shell inside the running container with
docker exec -it <container_id> /bin/bash(or/bin/shfor Alpine) to inspect processes and filesystem - Check running processes inside the container using
docker exec <container_id> ps auxto confirm expected services are running - Inspect network connectivity by running
docker exec <container_id> netstat -tlnporss -tlnpto check if services listen on expected ports - View resource usage and limits with
docker stats <container_id>to detect OOM (Out Of Memory) or CPU throttling - Check the container's environment variables with
docker exec <container_id> envto verify configuration was passed correctly - Examine mounted volumes with
docker inspect <container_id> | grep -A 5 Mountsto confirm volume paths and permissions
Code
#!/bin/bash
# Comprehensive Docker container debugging script
CONTAINER=$1
if [ -z "$CONTAINER" ]; then
echo "Usage: $0 <container_id_or_name>"
exit 1
fi
echo "=== CONTAINER STATUS ==="
docker ps -a --filter "id=$CONTAINER" --format "table {{.ID}}\t{{.Status}}\t{{.Ports}}"
echo -e "\n=== RECENT LOGS (last 50 lines) ==="
docker logs --tail 50 "$CONTAINER" 2>&1 | head -50
echo -e "\n=== RUNNING PROCESSES ==="
docker exec "$CONTAINER" ps aux 2>/dev/null || echo "Could not retrieve processes"
echo -e "\n=== NETWORK LISTENERS ==="
docker exec "$CONTAINER" netstat -tlnp 2>/dev/null || docker exec "$CONTAINER" ss -tlnp 2>/dev/null || echo "netstat/ss not available"
echo -e "\n=== RESOURCE USAGE ==="
docker stats "$CONTAINER" --no-stream --format "table {{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}"
echo -e "\n=== ENVIRONMENT VARIABLES ==="
docker exec "$
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Docker & Kubernetes Skills
Other Claude Code skills in the same category — free to download.
Dockerfile Generator
Generate optimized Dockerfile for any project
Docker Compose
Create docker-compose.yml for multi-service apps
K8s Deployment
Generate Kubernetes deployment manifests
K8s Service
Create Kubernetes service and ingress configs
Helm Chart
Create Helm chart for application
Docker Multistage
Optimize Docker builds with multi-stage builds
K8s ConfigMap
Create ConfigMaps and Secrets management
Docker Security
Audit and fix Dockerfile security issues
Want a Docker & Kubernetes skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.