技能库
智客分类:运维与云
docker-troubleshooting
Docker Troubleshooting
Guidance for debugging and troubleshooting Docker issues. Covers container startup failures (exit codes, docker logs, inspect), disk space exhaustion (system df/prune, log rotation), OOM and resource pressure (memory limits, stats), network connectivity problems (network inspect, iptables, DNS resolution), storage issues (permission denied, volume inspection), daemon problems (dockerd startup, socket permissions), and common error diagnosis. Use when the user asks about docker troubleshooting, docker debug, OOM, disk full, network issues, docker not starting, container crash, or needs to investigate Docker problems. 使用场景:docker 排查、docker debug、容器问题、OOM、磁盘满、网络不通、启动失败、配置问题.
SKILL.md / Agent 安装方式 SKILL.md 原文
93 安装量
官方网址:skills.sh
技能介绍
先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。
做什么
调试和排除多克问题的指导. 涵盖容器启动失败( 退出代码、 docker 日志、 检查)、 磁盘空间耗尽( system df/ prune, 日志旋转)、 OOM 和资源压力( memary limit, stats), 网络连接问题( 网络检查, iptables, DNS 解析), 存储问题( 拒绝许可, 量检查), 守护进程问题( docker 启动, socket 权限), 常见错误诊断
何时用
** 用户提到时总是使用这种技能:**
代理如何加载
按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Docker Troubleshooting — 问题排查与调试、When to Use、Diagnostic Framework、Container Startup Failure、Exit Code Reference、Quick diagnosis。
文件分析
文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。
Docker Troubleshooting — 问题排查与调试 When to Use Diagnostic Framework Container Startup Failure Exit Code Reference Quick diagnosis Disk Space Exhaustion Check disk usage What's using space? Clean up Log rotation (prevent future issues) OOM (Out of Memory)
· 许可:Apache-2.0
来源分类:skills.sh agent-skill
来源与网址
namedocker-troubleshooting
descriptionGuidance for debugging and troubleshooting Docker issues. Covers container startup failures (exit codes, docker logs, inspect), disk space exhaustion (system df/prune, log rotation), OOM and resource pressure (memory limits, stats), network connectivity problems (network inspect, iptables, DNS resolution), storage issues (permission denied, volume inspection), daemon problems (dockerd startup, socket permissions), and common error diagnosis. Use when the user asks about docker troubleshooting, docker debug, OOM, disk full, network issues, docker not starting, container crash, or needs to investigate Docker problems. 使用场景:docker 排查、docker debug、容器问题、OOM、磁盘满、网络不通、启动失败、配置问题.
许可 Apache-2.0
发现技能 客户端向 Agent 提供名称与描述目录。
匹配与调用 用户指定或任务匹配后,载入 SKILL.md 指令。
按需加载 按步骤读取参考文档、使用脚本与素材。
具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗
先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。
交给 Agent 安装
复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。
把 Agent Skill「docker-troubleshooting」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-0be7159c5c299084-Docker-%E8%A7%A3%E5%86%B3%E9%97%AE%E9%A2%98.html
请存为 .cursor/skills/docker-troubleshooting/SKILL.md 或 .claude/skills/docker-troubleshooting/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
复制安装提示词 GitHub 完整包 ↗
终端安装 · Skills CLI
需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。
npx skills add 'https://github.com/full-stack-skills/docker-skills' --list
复制查看命令
目标客户端
安装时交互选择 Codex Claude Code Cursor
安装范围
当前项目 我的所有项目
npx skills add 'https://github.com/full-stack-skills/docker-skills' --skill 'docker-troubleshooting' 复制安装命令
CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。
SKILL.md 原文 可复制,不会改动源文件
复制 SKILL.md
恢复原文
阅读排版
---
name: docker-troubleshooting
description: Guidance for debugging and troubleshooting Docker issues. Covers container startup failures (exit codes, docker logs, inspect), disk space exhaustion (system df/prune, log rotation), OOM and resource pressure (memory limits, stats), network connectivity problems (network inspect, iptables, DNS resolution), storage issues (permission denied, volume inspection), daemon problems (dockerd startup, socket permissions), and common error diagnosis. Use when the user asks about docker troubleshooting, docker debug, OOM, disk full, network issues, docker not starting, container crash, or needs to investigate Docker problems. 使用场景:docker 排查、docker debug、容器问题、OOM、磁盘满、网络不通、启动失败、配置问题.
license: Apache-2.0
---
# Docker Troubleshooting — 问题排查与调试
Systematic approach to diagnosing and resolving common Docker issues.
## When to Use
**ALWAYS use this skill when the user mentions:**
- "docker 排查", "docker debug", "容器问题"
- "容器启动失败", "exit code", "crash"
- "OOM", "磁盘满", "disk full"
- "网络不通", "network issues"
- "docker daemon", "daemon not running"
## Diagnostic Framework
```
1. Check container state → docker ps -a, docker inspect
2. Check logs → docker logs --tail 100
3. Check resources → docker stats, docker system df
4. Check exit code → docker inspect --format='{{.State.ExitCode}}'
5. Interactive debug → docker run --rm -it image sh
```
## Container Startup Failure
### Exit Code Reference
| Code | Meaning | Action |
|------|---------|--------|
| **0** | Success | — |
| **1** | Application error | Check `docker logs` |
| **125** | Docker daemon error | Check daemon status |
| **126** | Command cannot execute | Check permissions |
| **127** | Command not found | Check CMD/ENTRYPOINT path |
| **137** | SIGKILL (OOM or docker kill) | Check memory limits |
| **139** | SIGSEGV (segfault) | Application bug |
| **143** | SIGTERM (graceful stop) | Health check timeout? |
```bash
# Quick diagnosis
docker ps -a | grep Exited
docker inspect --format='{{.State.ExitCode}} {{.State.Error}}' container
docker logs container
```
## Disk Space Exhaustion
```bash
# Check disk usage
docker system df
# What's using space?
docker system df -v # Verbose breakdown
# Clean up
docker system prune -a # Remove all unused: images, containers, volumes, networks
docker image prune -a # Unused images only
docker volume prune # Unused volumes only
# Log rotation (prevent future issues)
docker run --log-opt max-size=10m --log-opt max-file=3 myapp
```
## OOM (Out of Memory)
```bash
# Check if container was OOM-killed
docker inspect --format='{{.State.OOMKilled}}' container
# Check memory usage
docker stats --no-stream
# Solution: increase memory limit
docker update --memory=1g --memory-swap=1g container
```
## Network Connectivity
```bash
# Check network configuration
docker network inspect bridge
docker exec container ip addr show
docker exec container ping other-container
# DNS check
docker exec container nslookup other-container
docker exec container cat /etc/resolv.conf
# Host networking check
iptables -t nat -L DOCKER -n # Port forwarding rules
```
## Permission Issues
```bash
# Bind mount permission denied
# Solution 1: Match UID
docker run -u $(id -u):$(id -g) -v $PWD:/app myapp
# Solution 2: Fix permissions in entrypoint
# In entrypoint script: chown -R appuser:appgroup /data
# Docker socket permission
sudo usermod -aG docker $USER # Add user to docker group
newgrp docker # Refresh group (or re-login)
```
## Workflow — 排查流程
Step 1: **查看状态**: `docker ps -a` → 确认退出码和 OOMKilled
Step 2: **查看日志**: `docker logs --tail 100 ` 获取错误信息
Step 3: **深入检查**: `docker inspect` → 检查网络/挂载/资源限制
Step 4: **交互调试**: `docker run -it --rm --entrypoint sh ` 进入排查
Step 5: **资源排查**: `docker stats` + `docker system df` 检查 CPU/内存/磁盘
## Gotchas — Common Pitfalls
- **`docker system prune` is destructive**: Removes ALL unused objects. Don't run blindly in production. → **Recovery**: Use `docker system df` first to preview; add `--filter "until=24h"` for safe cleanup; never run `prune -a` without confirmation.
- **Logs fill disk silently**: JSON-file driver has NO rotation by default. A noisy app can fill the disk in hours. → **Recovery**: `docker run --log-opt max-size=10m --log-opt max-file=3 app`; existing: `truncate -s 0 $(docker inspect -f '{{.LogPath}}' myapp)`.
- **OOMKilled=TRUE but no error in logs**: SIGKILL can't be logged. → **Recovery**: Check `docker inspect -f '{{.State.OOMKilled}}' myapp`; increase memory: `docker update --memory 512m myapp`.
- **Exited (0) but service not working**: Application started but crashed after health check passed. → **Recovery**: `docker logs --tail 100 myapp`; check if app listens on 0.0.0.0 (not 127.0.0.1); verify with `docker exec myapp netstat -tlnp`.
## Boundary — 能力边界(适用与不适用场景)
| 分类 | 场景 | 说明 |
|------|------|------|
| ✅ 能做 | 容器启动失败排查 | 退出码分析 + docker logs + inspect |
| ✅ 能做 | 磁盘/日志/资源问题 | docker system df + prune + log rotation |
| ✅ 能做 | OOM/CPU 排查 | docker stats + --memory 限制 + OOMKilled |
| ⚠️ 需条件 | 网络包级分析 | 需 tcpdump/Wireshark + 网络知识 |
| ⚠️ 需条件 | 内核级问题 | 需 Linux 内核调试技能 |
| ❌ 超范围 | 应用代码 bug 修复 | 开发者修复代码 |
| ❌ 超范围 | 生产环境部署 | 使用 `docker-production` |
| ❌ 超范围 | 安全漏洞修复 | 使用 `docker-security` + `docker-scout` |
## When NOT to Use This Skill
| ❌ Skip | ✅ Use Instead |
|---------|---------------|
| Setting up production | `docker-production` |
| Security issues | `docker-security` |
| Performance tuning | `docker-run` (resource limits) |
| Docker basics | `docker-basics` |
## Security & Stability
- `docker exec` into production containers can expose sensitive data. Prefer log-based debugging.
- `docker system prune -a` removes ALL unused images and volumes — use with caution in production.
- Inspecting containers with `--privileged` debug tools can bypass security controls.
- Never expose Docker socket (`/var/run/docker.sock`) to containers for debugging — it grants root access.
- Rotate debug logs — they may contain sensitive information. Use log drivers with TTL.
## 📚 官方文档参考
| 文档 | 地址 |
|------|------|
| Docker 引擎故障排查 | https://docs.docker.com/engine/troubleshoot/ |
| docker logs 命令 | https://docs.docker.com/reference/cli/docker/container/logs/ |
| docker inspect | https://docs.docker.com/reference/cli/docker/inspect/ |
| Docker CLI 参考 | https://docs.docker.com/reference/cli/docker/ |
| 守护进程配置 | https://docs.docker.com/reference/cli/dockerd/ |
| 常见问题 FAQ | https://docs.docker.com/faq/ |
## 🧭 Docker Skills Journey
> 📍 **You are here: `docker-troubleshooting` — 问题排查**
**← Previous**: `docker-production`
相关技能
运维与云
用于容器管理,图像操作,调试的基本道克命令和工作流程.
运维与云
从开放的代理技能生态系统中发现并安装技能. 使用时:(1)用户问"我如何做X",X可能拥有现有技能,(2)用户说"为X找到技能"或"是否为X有技能",(3)用户问"你能否做X",X是专门能力,(4)用户想扩展代理能力,(5)用户想搜索工具,模板,或工作流程,(6)用户提到他们希望…
运维与云
构建,部署,评价,优化,微调,管理微软创始代理,模型,资源最终结束. 用法:铸造、azd ai代理、azd 提供/部署、托管代理脚手架/开发/运行/部署/拖放、即时代理创建、创建代理、更新代理、添加代理工具、援引代理、代理.yaml、评估代理、批量活化、连续活化、持续监测、代理C…
运维与云
执行已有.azure/部署计划.md和基础设施文件的ALREADY-PREPARED应用程序的Azure部署。 当用户向 CREATE 请求新应用程序时, 请不要使用此技能 。 这种技能运行了 azd上行, azd 部署, trarraform 应用, 和 az 部署命令带有内置…