tencentcloud/octop-harness/docker-management
Claude Code and agent skill by tencentcloud/octop-harness
- community
Checking that the SKILL.md file is still in the repository.
管理 Docker 容器、镜像、卷、网络和 Compose 栈——生命周期操作、调试、清理和 Dockerfile 优化。
Install
npx vskill@latest install tencentcloud/octop-harness/docker-managementSKILL.md
The same SKILL.md was published earlier as tencentcloud/octop-harness/docker-management.
Docker 管理
Harness-agent 工具
本技能从 Octop 移植。使用以下 harness/deepagents 工具:
| 概念 | 工具 | |
|---|---|---|
| Shell | execute | |
| 读/写/编辑文件 | read_file, write_file, edit_file | |
| 查找文件/搜索内容 | glob, grep | |
| 获取 URL | web_fetch | |
| 浏览器自动化 | browser_use | |
| 子代理工作 | task | |
| 记忆 | memory_store, memory_recall, memory_search |
内置技能文件位于 /_builtin_skills/<name>/。用户安装的技能位于 /skills/<name>/。
使用标准 Docker CLI 命令管理 Docker 容器、镜像、卷、网络和 Compose 栈。除了 Docker 本身外无需额外依赖。
何时使用
- 运行、停止、重启、移除或检查容器
- 构建、拉取、推送、标记或清理 Docker 镜像
- 使用 Docker Compose(多服务栈)
- 管理卷或网络
- 调试崩溃的容器或分析日志
- 检查 Docker 磁盘使用或释放空间
- 审查或优化 Dockerfile
先决条件
- Docker 引擎已安装并运行
- 用户已添加到
docker组(或使用sudo) - Docker Compose v2(包含在现代 Docker 安装中)
快速检查:
快速参考
| 任务 | 命令 | |
|---|---|---|
| 运行容器(后台) | docker run -d --name NAME IMAGE | |
| 停止 + 移除 | docker stop NAME && docker rm NAME | |
| 查看日志(跟随) | docker logs --tail 50 -f NAME | |
| 进入容器 Shell | docker exec -it NAME /bin/sh | |
| 列出所有容器 | docker ps -a | |
| 构建镜像 | docker build -t TAG . | |
| Compose 启动 | docker compose up -d | |
| Compose 停止 | docker compose down | |
| 磁盘使用 | docker system df | |
| 清理悬空镜像 | docker image prune && docker container prune |
流程
1. 确定领域
弄清楚请求属于哪个领域:
- 容器生命周期 → run、stop、start、restart、rm、pause/unpause
- 容器交互 → exec、cp、logs、inspect、stats
- 镜像管理 → build、pull、push、tag、rmi、save/load
- Docker Compose → up、down、ps、logs、exec、build、config
- 卷和网络 → create、inspect、rm、prune、connect
- 故障排除 → 日志分析、退出码、资源问题
2. 容器操作
运行新容器:
关键标志:-d 分离模式、-it 交互+tty、--rm 自动移除、-p 端口(主机:容器)、-e 环境变量、-v 卷、--name 名称、--restart 重启策略。
管理运行中的容器:
与容器交互:
3. 镜像管理
4. Docker Compose
最小 compose.yml 示例:
5. 卷和网络
6. 磁盘使用和清理
始终在清理前进行诊断:
警告: 绝不在未与用户确认的情况下运行 docker system prune -a --volumes。这会移除可能包含重要数据的命名卷。
陷阱
| 问题 | 原因 | 修复 | |
|---|---|---|---|
| 容器立即退出 | 主进程完成或崩溃 | 检查 docker logs NAME,尝试 docker run -it --entrypoint /bin/sh IMAGE | |
| "端口已被分配" | 另一个进程正在使用该端口 | docker ps 或 lsof -i :PORT 查找它 | |
| "设备上没有剩余空间" | Docker 磁盘已满 | docker system df 然后定向清理 | |
| 无法连接到容器 | 应用在容器内绑定到 127.0.0.1 | 应用必须绑定到 0.0.0.0,检查 -p 映射 | |
| 卷权限被拒绝 | 主机与容器的 UID/GID 不匹配 | 使用 --user $(id -u):$(id -g) 或修复权限 | |
| Compose 服务无法相互访问 | 网络或服务名称错误 | 服务使用服务名称作为主机名,检查 docker compose config | |
| 构建缓存不工作 | Dockerfile 中层顺序错误 | 将不常变化的层放在前面(依赖项在源代码之前) | |
| 镜像太大 | 无多阶段构建,无 .dockerignore | 使用多阶段构建,添加 .dockerignore |
验证
任何 Docker 操作后,验证结果:
- 容器已启动? →
docker ps(检查状态是否为 "Up") - 日志干净? →
docker logs --tail 20 NAME(无错误) - 端口可访问? →
curl -s http://localhost:PORT或docker port NAME - 镜像已构建? →
docker images | grep TAG - Compose 栈健康? →
docker compose ps(所有服务 "running" 或 "healthy") - 磁盘已释放? →
docker system df(比较之前/之后)
Dockerfile 优化技巧
审查或创建 Dockerfile 时,建议以下改进:
- 多阶段构建——分离构建环境和运行时以减小最终镜像大小
- 层排序——将依赖项放在源代码之前,以便更改不会使缓存层失效
- 合并 RUN 命令——更少的层,更小的镜像
- 使用 .dockerignore——排除
node_modules、.git、__pycache__等 - 固定基础镜像版本——
node:20-alpine而不是node:latest - 以非 root 运行——添加
USER指令以提高安全性 - 使用 slim/alpine 基础镜像——
python:3.12-slim而不是python:3.12
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingsrc/octop_harness/builtin/skills/zh/docker-management/SKILL.md
Popularity
- Repository stars
- 112
- Repository forks
- 66
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tencentcloud/octop-harness/docker-management)