1. docker manifest create
1.1. 描述
创建一个多架构镜像(manifest lists),并 push 到镜像仓库。
要创建多架构镜像,首先要在本地创建 manifest lists,指定您希望包含在清单列表中的组成映像。请注意,这是推送到镜像仓库的,所以如果您想推送到镜像仓库不是官方默认 hub.docker.com,您需要指定您的多架构镜像的镜像仓库地址或IP和端口。这类似于标记镜像并将其推送到外部镜像仓库。
在创建多架构镜像的本地副本之后,您可以选择对其进行注释 annotate。允许标注的是体系架构和操作系统(覆盖镜像的当前值)、操作系统特性和体系结构变体。最后,您需要将清单列表推送到所需的镜像仓库。详情参考 docker manifest annotate 和 docker manifest push
1.2. 帮助
# docker manifest create --help
Usage: docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...]
Create a local manifest list for annotating and pushing to a registry
EXPERIMENTAL:
docker manifest create is an experimental feature.
Experimental features provide early access to product functionality. These
features may change between releases without warning, or can be removed from a
future release. Learn more about experimental features in our documentation:
https://docs.docker.com/go/experimental/
Options:
-a, --amend Amend an existing manifest list
--insecure Allow communication with an insecure registry
1.3. 选项
名称,简写 | 默认值 | 描述 |
---|---|---|
-a, --amend | - | 修改一个已经存在的多架构镜像 |
--insecure | - | 允许使用不安全的(非合法证书的 https)镜像仓库 |
1.4. 示例
- 将 redis 的 arm64 和 amd64 镜像构建成一个多架构镜像
# docker manifest create harbor.cncfstack.com/library/redis:6.2.6-multi harbor.cncfstack.com/library/redis:6.2.6-amd64 harbor.cncfstack.com/library/redis:6.2.6-arm64
Created manifest list harbor.cncfstack.com/library/redis:6.2.6-multi
构建完成后,可以使用 docker manifest inspect
查看多架构镜像信息
# docker manifest inspect harbor.cncfstack.com/library/redis:6.2.6-multi
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1573,
"digest": "sha256:3991cfe7ed07a7080c79a3b52e38e81caf13f9aa013b0bf588807f4637176515",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 1572,
"digest": "sha256:6c1a95df60f12a3b014fa5c85a9c04e742eb2686db2a9f212d49974188ebf0ec",
"platform": {
"architecture": "arm64",
"os": "linux",
"variant": "v8"
}
}
]
}
然后使用 docker manifest push
将多架构镜像信息推送远程仓库
# docker manifest push harbor.cncfstack.com/library/redis:6.2.6-multi
sha256:89762437568f959988bcd9aefe08a8b41d6031defac406a3d9e0281efe07177a
1.5. 常见问题
在使用 docker manifest create
时,需要先将待合并的镜像推送到远程镜像仓库,否则在创建时会报错 no such manifest
# docker manifest create redis:6.2.6-mult redis:6.2.6-amd64 redis:6.2.6-arm64
no such manifest: docker.io/library/redis:6.2.6-amd64