mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-11 04:14:38 +00:00
- Enforce Level 1-3 structural numbering based on SUMMARY.md hierarchy - Remove structural numbering from Level 4+ headings - Eliminate single child headings by converting to bold text - Auto-inject summary text for headings with multiple children missing intro text - Exclude Appendix chapters from structural numbering - Avoid modifying code block contents - Add script to detect non-standard English usage in headers
1.1 KiB
1.1 KiB
9.2 使用 Buildx 构建镜像
本节涵盖了相关内容与详细描述,主要探讨以下几个方面:
9.2.1 使用
Buildx 的使用非常直观,绝大多数情况下可以替代 docker build 命令。
你可以直接使用 docker buildx build 命令构建镜像。
$ docker buildx build .
[+] Building 8.4s (23/32)
=> ...
Buildx 使用 BuildKit 引擎进行构建,支持许多新的功能,具体参考 Buildkit 一节。
使用 bake
docker buildx bake 是一个高级构建命令,支持从 HCL、JSON 或 Compose 文件中定义构建目标,实现复杂的流水线构建。
## 从 Compose 文件构建所有服务
$ docker buildx bake
## 仅构建指定目标
$ docker buildx bake web
生成 SBOM
Buildx 支持在构建时直接生成 SBOM (Software Bill of Materials),这对于软件供应链安全至关重要。
$ docker buildx build --sbom=true -t myimage .
该命令会在构建结果中包含 SPDX 或 CycloneDX 格式的 SBOM 数据。