跳到主内容
智客 ZICQ

技能库 智客分类:运维与云 docker

Docker

基于集装箱的开发,为孤立,可再生的环境. 当运行 npm 命令、 安装软件包、 执行代码或管理项目依赖性时使用 。 触发短语包括"npm安装","运行构建","启动服务器","安装软件包"等,或任何代码执行请求.

9 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

基于集装箱的开发,用于孤立、可再生的环境

何时用

Docker 执行

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Docker Development Skill、Core Principle、Pre-Flight Check (MANDATORY)、Navigate to project root first、Start container、Verify it started。

文件分析

文件分析:除 SKILL.md 外,正文还引用了 scripts/,属于带资源的技能包,代理会按需再读这些文件。

官方 description(原文)

Container-based development for isolated, reproducible environments. Use when running npm commands, installing packages, executing code, or managing project dependencies. Trigger phrases include "npm install", "run the build", "start the server", "install package", or any code execution request.

Docker Development SkillCore PrinciplePre-Flight Check (MANDATORY)Navigate to project root firstStart containerVerify it startedCheck why it exitedRemove and restartQuick ReferenceCheck Container StatusList running containers for current projectCheck container logs

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
docker
description
Container-based development for isolated, reproducible environments. Use when running npm commands, installing packages, executing code, or managing project dependencies. Trigger phrases include "npm install", "run the build", "start the server", "install package", or any code execution request.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「docker」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-e54ccef512fa33eb-%E5%A4%B9%E5%85%8B.html
请存为 .cursor/skills/docker/SKILL.md 或 .claude/skills/docker/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/wrsmith108/claude-code-docker-skill 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/wrsmith108/claude-code-docker-skill' --list

npx skills add 'https://github.com/wrsmith108/claude-code-docker-skill' --skill 'docker'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: docker description: Container-based development for isolated, reproducible environments. Use when running npm commands, installing packages, executing code, or managing project dependencies. Trigger phrases include "npm install", "run the build", "start the server", "install package", or any code execution request. --- # Docker Development Skill Execute all package installations and code execution inside Docker containers. This keeps the host machine clean and ensures consistent environments across projects. ## Core Principle **NEVER run `npm`, `node`, `npx`, or project scripts directly on the host machine.** Instead, use `docker exec` or ensure the container is running the dev server. ## Pre-Flight Check (MANDATORY) **Before running ANY npm/node command, Claude Code MUST verify the container is running.** Run this check first: ```bash docker ps --filter "name=" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" ``` **Expected output:** ``` NAMES STATUS PORTS -dev-1 Up X minutes 0.0.0.0:3000->3000/tcp ``` **If container is NOT running:** ```bash # Navigate to project root first cd /path/to/your/project # Start container docker-compose --profile dev up dev -d # Verify it started docker ps --filter "name=" ``` **If container shows "Exited":** ```bash # Check why it exited docker logs -dev-1 --tail 20 # Remove and restart docker-compose --profile dev down docker-compose --profile dev up dev -d ``` ## Quick Reference ### Check Container Status ```bash # List running containers for current project docker ps --filter "name=" # Check container logs docker logs -dev-1 --tail 50 # Check if dev server is responding curl -s http://localhost:3000 > /dev/null && echo "Server running" || echo "Server not running" ``` ### Start/Stop Containers ```bash # Start development container (from project root) docker-compose --profile dev up dev -d # Stop container docker-compose --profile dev down # Restart container docker-compose --profile dev restart dev # Rebuild after Dockerfile changes docker-compose --profile dev up dev -d --build ``` ### Execute Commands Inside Container ```bash # Install a package docker exec -it -dev-1 npm install # Install dev dependency docker exec -it -dev-1 npm install -D # Run tests docker exec -it -dev-1 npm test # Run type checking docker exec -it -dev-1 npm run typecheck # Run linting docker exec -it -dev-1 npm run lint # Run build docker exec -it -dev-1 npm run build # Open shell inside container docker exec -it -dev-1 /bin/sh # Run any arbitrary command docker exec -it -dev-1 ``` ## When to Use Docker exec | Operation | Use docker exec? | Reason | |-----------|------------------|--------| | `npm install` | ✅ Yes | Packages install in container | | `npm run dev` | ❌ No | Already running via docker-compose | | `npm test` | ✅ Yes | Tests run in container environment | | `npm run build` | ✅ Yes | Build happens in container | | `git` commands | ❌ No | Git runs on host (manages files) | | File editing | ❌ No | Volume mount syncs automatically | | Database migrations | ✅ Yes | Uses container's Node environment | ## Container Architecture ``` ┌─────────────────────────────────────────────────────────────┐ │ HOST (macOS/Linux/Windows) │ │ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ Docker Container (-dev-1) │ │ │ │ │ │ │ │ Node 20 Alpine │ │ │ │ └── node_modules/ (container-only) │ │ │ │ └── Dev server (port 3000) │ │ │ │ │ │ │ │ Volume Mounts: │ │ │ │ └── .:/app (source code sync) │ │ │ │ └── node_modules:/app/node_modules (persist deps) │ │ │ └─────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ Port 3000 mapped │ │ │ │ │ ▼ │ │ http://localhost:3000 │ └─────────────────────────────────────────────────────────────┘ ``` ## Volume Mount Behavior The `docker-compose.yml` mounts the project directory into the container: ```yaml volumes: - .:/app # Source code (synced) - /app/node_modules # Dependencies (container-only) ``` **What this means:** - Source code changes on host are immediately visible in container - `node_modules/` in container is separate from any on host - Hot reload works automatically with most frameworks ## Troubleshooting ### Container Not Running ```bash # Check if container exists docker ps -a --filter "name=" # If exited, check why docker logs -dev-1 # Restart docker-compose --profile dev up dev -d ``` ### Port Already in Use ```bash # Find what's using the port lsof -i :3000 # Kill the process or change port in docker-compose.yml ``` ### Module Not Found Errors ```bash # Rebuild container with fresh dependencies docker-compose --profile dev down docker-compose --profile dev build --no-cache dev docker-compose --profile dev up dev -d ``` ### File Changes Not Reflecting ```bash # Check volume mounts docker inspect -dev-1 | grep -A 10 "Mounts" # Restart container docker-compose --profile dev restart dev ``` ## Project Configuration After installing this skill, update the placeholders for your project: | Setting | Example Value | |---------|---------------| | Container name | `my-app-dev-1` | | Port | 3000 (or your app's port) | | Node version | 20 (Alpine) | | Dev command | `npm run dev -- --host 0.0.0.0` | ### Environment Variables Required env vars are loaded from `.env` file via docker-compose. If a command needs a specific env var: ```bash docker exec -it -e MY_VAR=value -dev-1 ``` ## Best Practices 1. **Always check container status** before running commands 2. **Use `docker exec`** for all npm/node operations 3. **Let volume mounts** handle file syncing (no manual copying) 4. **Rebuild image** after changing `package.json` or `Dockerfile` 5. **Check logs** if something isn't working ## Integration with Claude Code When Claude Code needs to: | Task | Action | |------|--------| | Install dependency | `docker exec -it -dev-1 npm install ` | | Run tests | `docker exec -it -dev-1 npm test` | | Check types | `docker exec -it -dev-1 npm run typecheck` | | Build project | `docker exec -it -dev-1 npm run build` | | Start dev server | Container already runs it via docker-compose | | Edit files | Edit directly (volume mount syncs) | | Git operations | Run on host (not in container) | ## Sample docker-compose.yml ```yaml services: app: build: context: . dockerfile: Dockerfile ports: - "3000:3000" environment: - NODE_ENV=production env_file: - .env restart: unless-stopped dev: build: context: . dockerfile: Dockerfile.dev ports: - "3000:3000" volumes: - .:/app - /app/node_modules environment: - NODE_ENV=development env_file: - .env profiles: - dev ``` ## Sample Dockerfile.dev ```dockerfile FROM node:20-alpine WORKDIR /app # Install dependencies for native modules RUN apk add --no-cache python3 make g++ # Copy package files and any scripts needed for postinstall COPY package*.json ./ COPY scripts/ ./scripts/ # Install all dependencies RUN npm install # Copy source code COPY . . # Expose port EXPOSE 3000 # Set environment variables ENV HOST=0.0.0.0 ENV PORT=3000 ENV NODE_ENV=development # Start development server CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] ```

相关技能

运维与云

Docker Essentials

用于容器管理,图像操作,调试的基本道克命令和工作流程.

运维与云

Find Skills

从开放的代理技能生态系统中发现并安装技能. 使用时:(1)用户问"我如何做X",X可能拥有现有技能,(2)用户说"为X找到技能"或"是否为X有技能",(3)用户问"你能否做X",X是专门能力,(4)用户想扩展代理能力,(5)用户想搜索工具,模板,或工作流程,(6)用户提到他们希望…

运维与云

Microsoft Foundry

构建,部署,评价,优化,微调,管理微软创始代理,模型,资源最终结束. 用法:铸造、azd ai代理、azd 提供/部署、托管代理脚手架/开发/运行/部署/拖放、即时代理创建、创建代理、更新代理、添加代理工具、援引代理、代理.yaml、评估代理、批量活化、连续活化、持续监测、代理C…

运维与云

Azure Deploy

执行已有.azure/部署计划.md和基础设施文件的ALREADY-PREPARED应用程序的Azure部署。 当用户向 CREATE 请求新应用程序时, 请不要使用此技能 。 这种技能运行了 azd上行, azd 部署, trarraform 应用, 和 az 部署命令带有内置…