为所有架构(ARM、x86 等)构建 Docker 镜像
要构建多架构映像,需要使用名为buildx的 Docker 工具。
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v8 \
-t techiescamp/hey:latest \
--push .
- -platform 指定您想要构建图像的架构
- Linux/amd64 -> 64 位 Intel/AMD (x86_64)
- Linux/arm64 -> 64 位 ARM(Apple M1/M2、AWS Graviton)
- Linux/arm/v7 -> 32 位 ARM(较旧的 Raspberry Pi 设备)
- -t 镜像的名称以及标签
- -push 构建后推送此镜像