名称: docker-debugging 描述: Docker 容器调试和管理。用于调查容器问题、检查日志、资源使用情况或 Docker Compose 服务。 允许的工具: Bash(python *)
Docker 调试
身份验证
Docker 命令通过 Docker CLI 直接运行。不需要 API 密钥 - 必须在沙箱环境中访问 Docker 套接字。
可用脚本
所有脚本位于 .claude/skills/infrastructure-docker/scripts/
container_ps.py - 列出容器
python .claude/skills/infrastructure-docker/scripts/container_ps.py [--all]
container_logs.py - 获取容器日志
python .claude/skills/infrastructure-docker/scripts/container_logs.py --container NAME_OR_ID [--tail 100]
container_inspect.py - 检查容器
python .claude/skills/infrastructure-docker/scripts/container_inspect.py --container NAME_OR_ID
container_stats.py - 资源使用统计
python .claude/skills/infrastructure-docker/scripts/container_stats.py [--container NAME_OR_ID]
image_list.py - 列出 Docker 镜像
python .claude/skills/infrastructure-docker/scripts/image_list.py [--filter "reference=myapp*"]
compose_ps.py - 列出 Compose 服务
python .claude/skills/infrastructure-docker/scripts/compose_ps.py [--file docker-compose.yml] [--cwd /path]
compose_logs.py - 获取 Compose 服务日志
python .claude/skills/infrastructure-docker/scripts/compose_logs.py [--services "api,db"] [--tail 100]
调查工作流程
容器调试
1. 列出容器: container_ps.py --all
2. 检查日志: container_logs.py --container <名称> --tail 200
3. 检查资源: container_stats.py --container <名称>
4. 检查配置: container_inspect.py --container <名称>
Docker Compose 调试
1. 检查服务: compose_ps.py
2. 检查日志: compose_logs.py --services "api,worker" --tail 100
要避免的反模式
- 永远不要在没有明确用户批准的情况下运行破坏性命令 (docker rm, docker rmi, docker system prune)
- 始终使用 --tail 查看日志以避免输出过多
- 首先检查容器状态 在尝试执行进入之前