docker manifest
| 描述 | 管理 Docker 镜像清单和清单列表 |
|---|---|
| 用法 | docker manifest COMMAND |
实验性
此命令为实验性功能。
实验性功能旨在用于测试和反馈,因为其功能或设计可能会在版本之间更改,恕不另行通知,或者在未来的版本中可能被完全移除。
描述
docker manifest 命令本身不执行任何操作。为了操作清单或清单列表,必须使用其中一个子命令。
单个清单是关于镜像的信息,例如层、大小和摘要。docker manifest 命令还为您提供额外信息,
例如构建镜像的操作系统和架构。
清单列表是通过指定一个或多个(理想情况下是多个)镜像名称创建的镜像层列表。然后可以在 docker pull 和 docker run 命令中像使用镜像名称一样使用它,例如。
理想情况下,清单列表是由针对不同 os/arch 组合具有相同功能的镜像创建的。因此,清单列表通常被称为“多架构镜像”。但是,用户可以创建一个指向两个镜像的清单列表——一个用于 AMD64 架构上的 Windows,另一个用于 AMD64 架构上的 Darwin。
查看清单
$ docker manifest inspect --help
Usage: docker manifest inspect [OPTIONS] [MANIFEST_LIST] MANIFEST
Display an image manifest, or manifest list
Options:
--help Print usage
--insecure Allow communication with an insecure registry
-v, --verbose Output additional info including layers and platform
manifest create
Usage: docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...]
Create a local manifest list for annotating and pushing to a registry
Options:
-a, --amend Amend an existing manifest list
--insecure Allow communication with an insecure registry
--help Print usage
manifest annotate
Usage: docker manifest annotate [OPTIONS] MANIFEST_LIST MANIFEST
Add additional information to a local image manifest
Options:
--arch string Set architecture
--help Print usage
--os string Set operating system
--os-version string Set operating system version
--os-features stringSlice Set operating system feature
--variant string Set architecture variant
清单推送
Usage: docker manifest push [OPTIONS] MANIFEST_LIST
Push a manifest list to a repository
Options:
--help Print usage
--insecure Allow push to an insecure registry
-p, --purge Remove the local manifest list after push
使用不安全的镜像仓库
manifest 命令仅与注册表交互。因此,
它无法向引擎查询允许的不安全注册表列表。
为了允许 CLI 与不安全的注册表交互,某些 docker manifest
命令具有 --insecure 标志。对于每个事务,例如查询注册表的 create,
必须指定 --insecure 标志。此标志
告诉 CLI 此注册表调用可能会忽略安全问题,例如缺失
或自签名证书。同样,在连接到不安全
注册表的 manifest push 上,必须指定 --insecure 标志。如果未在不安全的注册表上使用此标志,
manifest 命令将无法找到符合默认要求的注册表。
示例
检查镜像的清单对象
$ docker manifest inspect hello-world
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 1520,
"digest": "sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 972,
"digest": "sha256:b04784fba78d739b526e27edc02a5a8cd07b1052e9283f5fc155828f4b614c28"
}
]
}
检查镜像的清单并获取 os/arch 信息
docker manifest inspect 命令接受一个可选的 --verbose 标志,该标志提供镜像名称 (Ref) 以及架构和操作系统 (Platform)。
与其他使用镜像名称的 Docker 命令一样,您可以通过标签或不通过标签来引用镜像,或者通过摘要(例如 hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f)来引用。
以下是使用 --verbose 标志检查镜像 manifest 的示例:
$ docker manifest inspect --verbose hello-world
{
"Ref": "docker.io/library/hello-world:latest",
"Digest": "sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f",
"SchemaV2Manifest": {
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 1520,
"digest": "sha256:1815c82652c03bfd8644afda26fb184f2ed891d921b20a0703b46768f9755c57"
},
"layers": [
{
"mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip",
"size": 972,
"digest": "sha256:b04784fba78d739b526e27edc02a5a8cd07b1052e9283f5fc155828f4b614c28"
}
]
},
"Platform": {
"architecture": "amd64",
"os": "linux"
}
}
创建并推送清单列表
要创建清单列表,您首先需要在本地create清单列表,方法是指定您希望包含在清单列表中的组成镜像。请记住,这会被推送到注册表,因此如果您想推送到 docker 注册表以外的注册表,您需要使用注册表名称或 IP 和端口创建您的清单列表。这与标记镜像并将其推送到外部注册表类似。
在创建了清单列表的本地副本后,您可以选择对其进行annotate。允许的注解包括架构和操作系统(覆盖镜像的当前值)、操作系统特性以及架构变体。
最后,你需要将清单列表 push 到目标仓库。以下是这三个命令的描述,以及将它们组合在一起的示例。
$ docker manifest create 45.55.81.106:5000/coolapp:v1 \
45.55.81.106:5000/coolapp-ppc64le-linux:v1 \
45.55.81.106:5000/coolapp-arm-linux:v1 \
45.55.81.106:5000/coolapp-amd64-linux:v1 \
45.55.81.106:5000/coolapp-amd64-windows:v1
Created manifest list 45.55.81.106:5000/coolapp:v1
$ docker manifest annotate 45.55.81.106:5000/coolapp:v1 45.55.81.106:5000/coolapp-arm-linux --arch arm
$ docker manifest push 45.55.81.106:5000/coolapp:v1
Pushed manifest 45.55.81.106:5000/coolapp@sha256:9701edc932223a66e49dd6c894a11db8c2cf4eccd1414f1ec105a623bf16b426 with digest: sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b
Pushed manifest 45.55.81.106:5000/coolapp@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f with digest: sha256:b64ca0b60356a30971f098c92200b1271257f100a55b351e6bbe985638352f3a
Pushed manifest 45.55.81.106:5000/coolapp@sha256:39dc41c658cf25f33681a41310372f02728925a54aac3598310bfb1770615fc9 with digest: sha256:df436846483aff62bad830b730a0d3b77731bcf98ba5e470a8bbb8e9e346e4e8
Pushed manifest 45.55.81.106:5000/coolapp@sha256:f91b1145cd4ac800b28122313ae9e88ac340bb3f1e3a4cd3e59a3648650f3275 with digest: sha256:5bb8e50aa2edd408bdf3ddf61efb7338ff34a07b762992c9432f1c02fc0e5e62
sha256:050b213d49d7673ba35014f21454c573dcbec75254a08f4a7c34f66a47c06aba
检查清单列表
$ docker manifest inspect coolapp:v1
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 424,
"digest": "sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b",
"platform": {
"architecture": "arm",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 424,
"digest": "sha256:b64ca0b60356a30971f098c92200b1271257f100a55b351e6bbe985638352f3a",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 425,
"digest": "sha256:df436846483aff62bad830b730a0d3b77731bcf98ba5e470a8bbb8e9e346e4e8",
"platform": {
"architecture": "ppc64le",
"os": "linux"
}
},
{
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 425,
"digest": "sha256:5bb8e50aa2edd408bdf3ddf61efb7338ff34a07b762992c9432f1c02fc0e5e62",
"platform": {
"architecture": "s390x",
"os": "linux"
}
}
]
}
推送到不安全的镜像仓库
以下是使用已知不安全仓库创建并推送 manifest list 的示例。
$ docker manifest create --insecure myprivateregistry.mycompany.com/repo/image:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-ppc64le:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-s390x:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-arm:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-armhf:1.0 \
myprivateregistry.mycompany.com/repo/image-windows-amd64:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-amd64:1.0
$ docker manifest push --insecure myprivateregistry.mycompany.com/repo/image:tag
注意
--insecure标志不是注解清单列表所必需的,因为注解是针对清单列表的本地存储副本。如果您正在对本地存储的清单列表执行docker manifest inspect,也可以跳过--insecure标志。请务必记住,引擎绝不会在docker pull上使用本地存储的清单列表。
子命令
| 命令 | 描述 |
|---|---|
docker manifest annotate | 向本地镜像 manifest 添加附加信息 |
docker manifest create | 创建本地 Manifest 列表,以便进行注释并推送到 Registry |
docker manifest inspect | 显示镜像清单或清单列表 |
docker manifest push | 将清单列表推送到仓库 |
docker manifest rm | 从本地存储中删除一个或多个清单列表 |