跳到主内容
智客 ZICQ

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

Docker Build

Expert guidance for the `docker build` command — building container images, tagging strategies, build arguments, image management and inspection. Covers `docker build` complete syntax, `--build-arg` usage, image tagging (`docker tag`), image inspection (`docker inspect`, `docker history`, `docker image ls`), pushing to registries (`docker push`), image pruning (`docker image prune`, `docker system prune`), and Docker BuildKit basics. Distinct from docker-dockerfile (focuses on Dockerfile authoring) and docker-buildx (focuses on multi-platform builds and advanced BuildKit). Use when the user asks about docker build, docker tag, docker push, docker images, docker image management, or how to build and manage Docker images. 使用场景:docker build 构建镜像、docker tag 打标签、docker push 推送镜像、docker images 镜

81 安装量

官方网址:skills.sh

技能介绍

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

做什么

" 筑桥 " 指挥的专家指导 -- -- 建立集装箱图像、标记战略、建立论据、图像管理和检查。 内容包括: " 多克构建 " 完整的语法、 " -- -- 建设 -- -- arg " 使用、图像标记( " 多克标签 " )、图像检查( " 多克检查 " )、 " 多克历史 " 、 " 多克图像IS " 、推向注册( " 多克推 " )、图像堆放( " docker image prune " 、 " Docker system prune " )和 " 多克构建基特基础 " 。 区别于 docker-dockerfile(以 Dockerfile 作者为焦点)和 docker-builtx(以多平台构建和高级构建 Kit 为焦点)

何时用

** 用户提到时总是使用这种技能:**

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Docker Build — 镜像构建与管理、When to Use、docker build — Complete Syntax、Essential Options、Basic build、Tag multiple tags at once。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Expert guidance for the `docker build` command — building container images, tagging strategies, build arguments, image management and inspection. Covers `docker build` complete syntax, `--build-arg` usage, image tagging (`docker tag`), image inspection (`docker inspect`, `docker history`, `docker image ls`), pushing to registries (`docker push`), image pruning (`docker image prune`, `docker system prune`), and Docker BuildKit basics. Distinct from docker-dockerfile (focuses on Dockerfile authoring) and docker-buildx (focuses on multi-platform builds and advanced BuildKit). Use when the user asks about docker build, docker tag, docker push, docker images, docker image management, or how to build and manage Docker images. 使用场景:docker build 构建镜像、docker tag 打标签、docker push 推送镜像、docker images 镜像管理、docker image 命令、构建参数 --build-arg、镜像标签、docker build 命令.

Docker Build — 镜像构建与管理When to Usedocker build — Complete SyntaxEssential OptionsBasic buildTag multiple tags at onceBuild from specific DockerfileBuild from Git repositoryBuild from stdinBuild Arguments (--build-arg)Pass build argumentsFrom file

· 许可:Apache-2.0

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
docker-build
description
Expert guidance for the `docker build` command — building container images, tagging strategies, build arguments, image management and inspection. Covers `docker build` complete syntax, `--build-arg` usage, image tagging (`docker tag`), image inspection (`docker inspect`, `docker history`, `docker image ls`), pushing to registries (`docker push`), image pruning (`docker image prune`, `docker system prune`), and Docker BuildKit basics. Distinct from docker-dockerfile (focuses on Dockerfile authoring) and docker-buildx (focuses on multi-platform builds and advanced BuildKit). Use when the user asks about docker build, docker tag, docker push, docker images, docker image management, or how to build and manage Docker images. 使用场景:docker build 构建镜像、docker tag 打标签、docker push 推送镜像、docker images 镜像管理、docker image 命令、构建参数 --build-arg、镜像标签、docker build 命令.
许可
Apache-2.0
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

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

安装这个技能

Skills CLI ↗

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

交给 Agent 安装

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

把 Agent Skill「docker-build」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-1c93e11d5a3481a5-Docker-%E6%9E%84%E5%BB%BA.html
请存为 .cursor/skills/docker-build/SKILL.md 或 .claude/skills/docker-build/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

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

npx skills add 'https://github.com/full-stack-skills/docker-skills' --list

npx skills add 'https://github.com/full-stack-skills/docker-skills' --skill 'docker-build'

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

阅读排版
--- name: docker-build description: Expert guidance for the `docker build` command — building container images, tagging strategies, build arguments, image management and inspection. Covers `docker build` complete syntax, `--build-arg` usage, image tagging (`docker tag`), image inspection (`docker inspect`, `docker history`, `docker image ls`), pushing to registries (`docker push`), image pruning (`docker image prune`, `docker system prune`), and Docker BuildKit basics. Distinct from docker-dockerfile (focuses on Dockerfile authoring) and docker-buildx (focuses on multi-platform builds and advanced BuildKit). Use when the user asks about docker build, docker tag, docker push, docker images, docker image management, or how to build and manage Docker images. 使用场景:docker build 构建镜像、docker tag 打标签、docker push 推送镜像、docker images 镜像管理、docker image 命令、构建参数 --build-arg、镜像标签、docker build 命令. license: Apache-2.0 --- # Docker Build — 镜像构建与管理 Complete reference for `docker build` and image lifecycle management. Build, tag, inspect, push, prune. ## When to Use **ALWAYS use this skill when the user mentions:** - "docker build", "怎么构建镜像", "docker build 命令" - "docker tag", "docker push", "推送镜像" - "docker images", "镜像管理", "docker image" - "--build-arg", "构建参数" - "docker history", "docker inspect", "镜像查看" - "docker image prune", "docker system prune", "清理镜像" | ✅ Use When | ❌ Use Instead | |------------|---------------| | Running docker build, tagging, pushing | | | Managing local images | | | Needing `docker build` CLI reference | | | Writing the Dockerfile itself | `docker-dockerfile` | | Multi-platform builds | `docker-buildx` | | BuildKit advanced features | `docker-buildx` | ## docker build — Complete Syntax ```bash docker build [OPTIONS] PATH | URL | - ``` ### Essential Options ```bash # Basic build docker build -t myapp:v1 . # Tag multiple tags at once docker build -t myapp:v1.2.3 -t myapp:latest -t ghcr.io/org/myapp:v1.2.3 . # Build from specific Dockerfile docker build -f Dockerfile.prod -t myapp:prod . # Build from Git repository docker build -t myapp https://github.com/user/repo.git#main # Build from stdin cat Dockerfile | docker build -t myapp - docker build -t myapp - <:) docker image prune # Remove all unused images docker image prune -a # Full system cleanup docker system prune -a --volumes # Check disk usage docker system df docker system df -v ``` ## Workflow — 推荐构建流程 Step 1: **准备 Dockerfile**: 已完成编写(或使用 `docker-dockerfile` 生成) Step 2: **配置构建参数**: 确认 --build-arg、--label、--target Step 3: **执行构建**: `docker build -t myapp:v1 -t myapp:latest .` Step 4: **验证镜像**: `docker images` / `docker history` / `docker inspect` Step 5: **推送仓库**: `docker push` 前 `docker login`,生产环境用 digest 固定 ## Gotchas — Common Pitfalls - **`docker build -t myapp .` sends entire context**: Without `.dockerignore`, sends node_modules/.git and everything. Use `.dockerignore` to minimize context. - **`docker build --no-cache` is slow**: Only use when truly needed. Normal builds reuse cached layers. - **`docker tag` is mutable**: Tags can be moved. For production, use digest (`@sha256:...`) instead of tag. - **`docker push` without login fails silently**: Always `docker login` first, or use CI credential helpers. - **`docker system prune -a` is destructive**: Removes ALL unused images, containers, networks. Don't run in production without confirmation. - **`docker build --pull` changes base image**: Your build may produce different output if base image was updated. ## Boundary — 能力边界(适用与不适用场景) | 分类 | 场景 | 说明 | |------|------|------| | ✅ 能做 | docker build 构建镜像 | 完整命令语法、上下文管理、多 tag | | ✅ 能做 | docker tag 打标签 | 命名规范、多 registry 标签 | | ✅ 能做 | docker push 推送镜像 | 仓库登录、digest 固定 | | ✅ 能做 | 镜像管理(inspect/history/prune) | 本地镜像生命周期 | | ⚠️ 需条件 | BuildKit 高级特性(secret/cache/ssh) | 使用 `docker-buildx` | | ⚠️ 需条件 | 网络不稳定时推送大镜像 | 配置 max-concurrent-uploads | | ❌ 超范围 | Dockerfile 编写 | 使用 `docker-dockerfile` | | ❌ 超范围 | 多平台构建(arm64/amd64) | 使用 `docker-buildx` | | ❌ 超范围 | CI/CD 流水线集成 | 使用 `docker-cicd` | ## When NOT to Use This Skill | ❌ Skip | ✅ Use Instead | |---------|---------------| | Writing the Dockerfile itself | `docker-dockerfile` | | Multi-platform/arm64 builds | `docker-buildx` | | BuildKit secrets/cache/SSH | `docker-buildx` | | Running containers | `docker-run` | | Docker basics | `docker-basics` | ## Security & Stability - Always scan built images with `docker scout` before pushing to production registry. - Use `docker build --pull` to ensure base images are up-to-date with security patches. - Never embed secrets in build args (`--build-arg` is visible in image history). Use BuildKit `--secret` instead. - Tag images with `--label` for metadata (version, git SHA, build timestamp) for audit trails. - Remove unused images regularly with `docker image prune` to free disk space and reduce attack surface. ## 📚 官方文档参考 | 文档 | 地址 | |------|------| | Docker Build | https://docs.docker.com/build/ | | docker build 命令 | https://docs.docker.com/reference/cli/docker/build/ | | docker tag | https://docs.docker.com/reference/cli/docker/image/tag/ | | docker push | https://docs.docker.com/reference/cli/docker/image/push/ | | docker image | https://docs.docker.com/reference/cli/docker/image/ | | Dockerfile 参考 | https://docs.docker.com/reference/dockerfile/ | ## 🧭 Docker Skills Journey > 📍 **You are here: `docker-build` — 镜像构建与管理** ``` basics → dockerfile → build → buildx → run → compose → ... ``` **→ Next**: `docker-buildx` — Multi-platform builds and BuildKit advanced features

相关技能

运维与云

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 部署命令带有内置…