docker manifest
| 描述 | 管理 Docker 镜像清单和清单列表 |
|---|---|
| 用法 | docker manifest COMMAND |
实验性
此命令是实验性的。
实验性功能旨在用于测试和反馈,因为它们的功能或设计可能会在版本之间未经警告而更改,或者在未来的版本中被完全删除。
描述
docker manifest 命令本身不执行任何操作。要对清单或清单列表进行操作,必须使用其中一个子命令。
单个清单是关于镜像的信息,例如层、大小和摘要。docker manifest 命令还提供额外信息,例如镜像构建所针对的操作系统和架构。
清单列表是通过指定一个或多个(理想情况下是多个)镜像名称创建的镜像层列表。然后,它可以像 docker pull 和 docker run 命令中的镜像名称一样使用,例如。
理想情况下,清单列表是由功能相同但适用于不同操作系统/架构组合的镜像创建的。因此,清单列表通常被称为“多架构镜像”。然而,用户也可以创建一个清单列表,指向两个镜像——一个用于 AMD64 上的 Windows,另一个用于 AMD64 上的 Darwin。
manifest inspect
$ 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
manifest push
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"
}
]
}
检查镜像清单并获取操作系统/架构信息
docker manifest inspect 命令带有一个可选的 --verbose 标志,该标志提供镜像名称(Ref),以及架构和操作系统(Platform)。
与其他接受镜像名称的 Docker 命令一样,您可以带标签或不带标签,或通过摘要(例如 hello-world@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f)引用镜像。
这是一个使用 --verbose 标志检查镜像清单的示例
$ 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"
}
}
]
}
推送到不安全注册表
这是一个使用已知的不安全注册表创建和推送清单列表的示例。
$ 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 | 向本地镜像清单添加额外信息 |
docker manifest create | 创建本地清单列表以进行注释并推送到注册表 |
docker manifest inspect | 显示镜像清单或清单列表 |
docker manifest push | 将清单列表推送到存储库 |
docker manifest rm | 从本地存储中删除一个或多个清单列表 |