docker-debugger
Debug Docker containers, fix Dockerfile issues, optimize images, and troubleshoot docker-compose. Use when having Docker problems, container issues, or optimizing Docker builds.
适合你,如果经常遇到 Docker 容器运行异常或构建缓慢的问题
/ 通过 npx 安装 校验哈希
npx oh-my-skill add pmkshar/marqaiskills/docker-debugger/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- pmkshar/marqaiskills/docker-debugger/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify pmkshar/marqaiskills/docker-debugger安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
0GitHub stars
~654上下文体积 · 单文件
索引托管
怎么用
商店整理自技能原文 · 版本 d5999f8 · 表述以原文为准它做什么
安装后,Claude 能诊断 Docker 容器问题、修复 Dockerfile 错误、优化镜像大小,并排查 docker-compose 配置。
什么时候触发
当你遇到 Docker 构建失败、容器启动后立即退出、网络连接异常或镜像体积过大等问题时触发。
装好后可以这样说
Claude 会检查退出码和日志,给出修复建议。
Claude 会检查网络配置和容器 IP。
技能原文 SKILL.md
Docker Debugger
Instructions
When debugging Docker issues:
- Identify the problem type: Build, runtime, networking, or performance
- Gather information using diagnostic commands
- Analyze logs and errors
- Apply fixes
Diagnostic Commands
# Check running containers docker ps -a # View container logs docker logs <container_id> --tail 100 -f # Inspect container docker inspect <container_id> # Check resource usage docker stats # View container processes docker top <container_id> # Execute shell in running container docker exec -it <container_id> /bin/sh # Check Docker disk usage docker system df # View build history docker history <image_name>
Common Issues & Solutions
1. Container exits immediately
# Check exit code
docker inspect <container_id> --format='{{.State.ExitCode}}'
# View last logs
docker logs <container_id>
Fixes:
- Ensure CMD/ENTRYPOINT runs a foreground process
- Check for missing dependencies
- Verify environment variables
2. Build fails
# Use multi-stage builds for smaller images FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM node:20-alpine AS runner WORKDIR /app COPY --from=builder /app/dist ./dist COPY --from=builder /app/node_modules ./node_modules CMD ["node", "dist/index.js"]
3. Networking issues
# List networks
docker network ls
# Inspect network
docker network inspect <network_name>
# Check container IP
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container>
4. Volume permission issues
# Create non-root user
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
# Set ownership
COPY --chown=appuser:appgroup . .
USER appuser
Dockerfile Best Practices
# 1. Use specific tags, not :latest FROM node:20.10-alpine # 2. Set working directory WORKDIR /app # 3. Copy dependency files first (better caching) COPY package*.json ./ RUN npm ci --only=production # 4. Copy source after dependencies COPY . . # 5. Use non-root user USER node # 6. Set proper labels LABEL maintainer="you@example.com" LABEL version="1.0" # 7. Use HEALTHCHECK HEALTHCHECK --interval=30s --timeout=3s \ CMD wget -q --spider http://localhost:3000/health || exit 1 # 8. Expose ports EXPOSE 3000 # 9. Use exec form for CMD CMD ["node", "server.js"]
docker-compose Debugging
# docker-compose.yml
services:
app:
build:
context: .
dockerfile: Dockerfile
# Add for debugging
stdin_open: true
tty: true
# Override command for debugging
command: /bin/sh
volumes:
- .:/app
environment:
- DEBUG=true
# Rebuild without cache docker-compose build --no-cache # View logs docker-compose logs -f app # Restart single service docker-compose restart app
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →
评论
登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。
…