
Container Debugging
- 437 installs
- 305 repo stars
- Updated March 4, 2026
- aj-geddes/useful-ai-prompts
container-debugging is an agent skill that diagnoses failing Docker or Kubernetes containers using structured prompts for logs, exec shells, health probes, and image-layer inspection for developers troubleshooting produc
About
container-debugging from aj-geddes/useful-ai-prompts provides structured agent prompts for diagnosing failing Docker and Kubernetes containers. The workflow guides systematic investigation across container logs, interactive exec shells, health and readiness probe results, and image-layer inspection to isolate crash loops, OOM kills, misconfigured entrypoints, and networking faults. Developers reach for container-debugging when pods or compose services exit unexpectedly, probes fail intermittently, or deployments roll back without an obvious application stack trace. The skill fits operations and on-call contexts where kubectl and docker CLI commands must be applied in a consistent order rather than ad-hoc guessing. Expect command-shaped prompts and checklists agents can follow to narrow root cause before code changes ship.
- Log and exit-code triage
- docker exec inspection flows
- Image and env validation
- Network and volume checks
Container Debugging by the numbers
- 437 all-time installs (skills.sh)
- Ranked #97 of 596 Debugging skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill container-debuggingAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 437 |
|---|---|
| repo stars | ★ 305 |
| Last updated | March 4, 2026 |
| Repository | aj-geddes/useful-ai-prompts ↗ |
How do you debug a crashing Kubernetes container?
Diagnose failing Docker or Kubernetes containers using structured prompts for logs, exec shells, health probes, and image-layer inspection.
Who is it for?
Developers on call for Docker or Kubernetes services who want agent-guided, repeatable container failure diagnosis.
Skip if: Local non-container development, initial Dockerfile authoring, or infrastructure provisioning without a failing workload to inspect.
When should I use this skill?
User reports crashing containers, failing K8s probes, pod restart loops, or needs docker/kubectl debugging guidance.
What you get
Root-cause findings from logs, probe status, exec inspection, and image-layer analysis with recommended remediation steps.
- Diagnostic findings
- Recommended remediation commands
Files
Container Debugging
Table of Contents
Overview
Container debugging focuses on issues within Docker/Kubernetes environments including resource constraints, networking, and application runtime problems.
When to Use
- Container won't start
- Application crashes in container
- Resource limits exceeded
- Network connectivity issues
- Performance problems in containers
Quick Start
Minimal working example:
# Check container status
docker ps -a
docker inspect <container-id>
docker stats <container-id>
# View container logs
docker logs <container-id>
docker logs --follow <container-id> # Real-time
docker logs --tail 100 <container-id> # Last 100 lines
# Connect to running container
docker exec -it <container-id> /bin/bash
docker exec -it <container-id> sh
# Inspect container details
docker inspect <container-id> | grep -A 5 "State"
docker inspect <container-id> | grep -E "Memory|Cpu"
# Check container processes
docker top <container-id>
# View resource usage
docker stats <container-id>
# Shows: CPU%, Memory usage, Network I/O
// ... (see reference guides for full implementation)Reference Guides
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Docker Debugging Basics | Docker Debugging Basics |
| Common Container Issues | Common Container Issues |
| Container Optimization | Container Optimization |
| Debugging Checklist | Debugging Checklist |
Best Practices
✅ DO
- Follow established patterns and conventions
- Write clean, maintainable code
- Add appropriate documentation
- Test thoroughly before deploying
❌ DON'T
- Skip testing or validation
- Ignore error handling
- Hard-code configuration values
Common Container Issues
Common Container Issues
Issue: Container Won't Start
Diagnosis:
1. docker logs <container-id>
2. Check exit code: docker inspect (ExitCode)
3. Verify image exists: docker images
4. Check entrypoint: docker inspect --format='{{.Config.Entrypoint}}'
Common Exit Codes:
0: Normal exit
1: General application error
127: Command not found
128+N: Terminated by signal N
137: Out of memory (SIGKILL)
139: Segmentation fault
Solutions:
- Fix application error
- Ensure required files exist
- Check executable permissions
- Verify working directory
---
Issue: Out of Memory
Symptoms: Exit code 137 (SIGKILL)
Debug:
docker stats <container-id>
# Check Memory usage vs limit
Solution:
docker run -m 512m <image>
# Increase memory limit
docker inspect (MemoryLimit)
# Check current limit
---
Issue: Port Already in Use
Error: "bind: address already in use"
Debug:
docker ps # Check running containers
netstat -tlnp | grep 8080 # Check port usage
Solution:
docker run -p 8081:8080 <image>
# Use different host port
---
Issue: Network Issues
Symptom: Cannot reach other containers
Debug:
docker network ls
docker inspect <container-id> | grep IPAddress
docker exec <container-id> ping <other-container>
Solution:
docker network create app-network
docker run --network app-network <image>Container Optimization
Container Optimization
Resource Limits:
Set in docker-compose:
version: '3'
services:
app:
image: myapp
environment:
- NODE_ENV=production
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
Limits: Maximum resources
Reservations: Guaranteed resources
---
Multi-Stage Builds:
FROM node:16 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM node:16-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY package*.json ./
RUN npm install --production
EXPOSE 3000
CMD ["node", "dist/index.js"]
Result: 1GB → 200MB image sizeDebugging Checklist
Debugging Checklist
Container Issues:
[ ] Container starts without error
[ ] Ports mapped correctly
[ ] Logs show no errors
[ ] Environment variables set
[ ] Volumes mounted correctly
[ ] Network connectivity works
[ ] Resource limits appropriate
[ ] Permissions correct
[ ] Dependencies installed
[ ] Entrypoint working
Kubernetes Issues:
[ ] Pod running (not Pending/CrashLoop)
[ ] All containers started
[ ] Readiness probes passing
[ ] Liveness probes passing
[ ] Resource requests/limits set
[ ] Network policies allow traffic
[ ] Secrets/ConfigMaps available
[ ] Logs show no errors
Tools:
docker:
- logs
- stats
- inspect
- exec
docker-compose:
- logs
- ps
- config
kubectl (Kubernetes):
- logs
- describe pod
- get events
- port-forwardDocker Debugging Basics
Docker Debugging Basics
# Check container status
docker ps -a
docker inspect <container-id>
docker stats <container-id>
# View container logs
docker logs <container-id>
docker logs --follow <container-id> # Real-time
docker logs --tail 100 <container-id> # Last 100 lines
# Connect to running container
docker exec -it <container-id> /bin/bash
docker exec -it <container-id> sh
# Inspect container details
docker inspect <container-id> | grep -A 5 "State"
docker inspect <container-id> | grep -E "Memory|Cpu"
# Check container processes
docker top <container-id>
# View resource usage
docker stats <container-id>
# Shows: CPU%, Memory usage, Network I/O
# Copy files from container
docker cp <container-id>:/path/to/file /local/path
# View image layers
docker history <image-name>
docker inspect <image-name>#!/bin/bash
# validate-config.sh - Validate infrastructure configuration
# Usage: ./validate-config.sh <config_file>
set -euo pipefail
CONFIG_FILE="${{1:?Usage: $0 <config_file>}}"
echo "Validating: $CONFIG_FILE"
# TODO: Add configuration validation logic
# - Check required fields
# - Validate syntax (YAML/JSON/HCL)
# - Verify referenced resources exist
# - Check for security best practices
echo "Validation complete."
# Infrastructure Configuration Starter
# TODO: Customize for your infrastructure setup
#
# Usage: Copy this file and modify for your environment
# --- Environment Configuration ---
environment: production
region: us-east-1
# --- Resource Definitions ---
# TODO: Add resource definitions specific to this skill's domain
# --- Security Settings ---
# TODO: Add security configuration
# --- Monitoring ---
# TODO: Add monitoring/alerting configuration
Related skills
How it compares
Use container-debugging for runtime failure triage; infrastructure-as-code skills address provisioning, not live pod diagnosis.
FAQ
What does container-debugging investigate?
container-debugging investigates failing Docker or Kubernetes workloads via structured prompts for logs, exec shells, health and readiness probes, and image-layer inspection to isolate crash and config faults.
When should developers invoke container-debugging?
container-debugging fits on-call scenarios with pod restart loops, probe failures, or unexpected container exits where kubectl and docker CLI steps must run in a consistent diagnostic order.