docker-management
它能做什么
这个工具可以帮你构建、优化和修复 Docker 容器与镜像中的问题。它允许你在这些容器中创建、运行和管理应用。
适用场景
- ✓当你需要创建一个文件,定义应用如何在容器中运行时(Dockerfile)。
- ✓当你为应用构建并命名 Docker 镜像时。
- ✓当你运行、停止或调试容器中的应用时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/docker-management/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我该如何为我的 Web 应用创建一个 Docker 镜像?”
每周 5 个新技能,1 分钟读完。
工作原理
你可以请它为你的应用创建一个指令文件(Dockerfile),基于它构建镜像,然后将该镜像作为容器运行。遇到的任何问题,这个工具也能帮你排查。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Docker Management
Build, run, and manage Docker containers for application deployment and development.
When to Use This Skill
Use this skill when:
- Creating and optimizing Dockerfiles
- Building and tagging Docker images
- Running and managing containers
- Debugging container issues
- Configuring Docker networking and volumes
- Implementing container security best practices
Execution Scope
Confirm the selected Docker context and project before any operation. Build instructions execute contributed commands; inspect the Dockerfile, build context, scripts and downloaded dependencies first. Image publication, shared-container stops and volume deletion need authorization for the exact target. Do not expose environment values, image history or logs containing credentials. These examples are independent fragments with project-specific assets, not a complete deployment.
Prerequisites
- Docker Engine installed (20.10+)
- Basic command line knowledge
- Understanding of application deployment
Dockerfile Best Practices
Multi-Stage Build
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build && npm prune --omit=dev
# Production stage
FROM node:20-alpine AS production
WORKDIR /app
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 -G nodejs
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
USER nodejs
EXPOSE 3000
CMD ["node", "dist/index.js"]
Layer Optimization
FROM python:3.12-slim
# Install dependencies first (cached unless requirements change)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code (changes frequently)
COPY . .
CMD ["python", "app.py"]
Security Hardening
FROM node:20-alpine
# Create non-root user
RUN addgroup -g 1001 appgroup && \
adduser -u 1001 -G appgroup -D appuser
WORKDIR /app
# Copy with proper ownership
COPY --chown=appuser:appgroup . .
# Drop privileges
USER appuser
# Use exec form for proper signal handling
CMD ["node", "server.js"]
Building Images
Basic Build
# Build with tag
docker build -t myapp:1.0 .
# Build with build args
docker build --build-arg NODE_ENV=production -t myapp:prod .
# Build for specific platform
docker build --platform linux/amd64 -t myapp:amd64 .
# Build with no cache
docker build --no-cache -t myapp:fresh .
Multi-Platform Builds
# Create builder
docker buildx create --name multiplatform --use
# Build for multiple architectures
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t myregistry/myapp:latest \
--push .
Running Containers
Basic Operations
# Run container
docker run -d --name myapp -p 8080:3000 myapp:latest
# Run with environment variables
docker run -d \
-e DATABASE_URL=postgres://localhost/db \
-e NODE_ENV=production \
myapp:latest
# Run with resource limits
docker run -d \
--memory="512m" \
--cpus="1.0" \
myapp:latest
# Run with restart policy
docker run -d --restart=unless-stopped myapp:latest
Volume Management
# Named volume
docker volume create mydata
docker run -v mydata:/app/data myapp:latest
# Bind mount
docker run -v "$(pwd)/config:/app/config:ro" myapp:latest
# tmpfs mount (memory)
docker run --tmpfs /tmp:rw,noexec,nosuid myapp:latest
Networking
# Create network
docker network create mynetwork
# Run on network
docker run -d --network mynetwork --name api myapp:latest
# Connect existing container
docker network connect mynetwork existing-container
# Expose specific ports
docker run -d -p 127.0.0.1:8080:3000 myapp:latest
Container Lifecycle
Management Commands
# List containers
docker ps -a
# Stop container
docker stop myapp
# Remove container
docker rm myapp
# Force remove running container
docker rm -f myapp
# Prune stopped containers
docker container prune -f
Logs and Monitoring
# View logs
docker logs myapp
# Follow logs
docker logs -f --tail 100 myapp
# View resource usage
docker stats myapp
# Inspect container
docker inspect myapp
Debugging Containers
Interactive Access
# Execute command in running container
docker exec -it myapp /bin/sh
# Run container with shell
docker run -it --rm myapp:latest /bin/sh
# Debug failed container
…
常见问题
什么是 Docker 容器?
它就像一个隔离的盒子,里面装着应用运行所需的一切:代码、库和工具。这样可以保证应用在任何电脑上都以相同的方式运行。
什么是 Dockerfile?
它是一个包含分步指令的文本文件,Docker 会按照它来构建镜像。它定义了运行环境,以及应用在容器内如何设置。
使用 Docker 需要会编程吗?
最好具备基本的命令行知识,并了解你的应用如何工作。具体的 Docker 命令,这个工具会帮你处理。
详情
作者的原始描述
Build, optimize, and troubleshoot Docker containers and images.
热度
- GitHub 星标
- 48k
- 排名
- #4476
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。