Docker清单
描述 | 管理 Docker 映像清单和清单列表 |
---|---|
用法 | docker manifest COMMAND |
该命令是实验性的
实验性功能旨在用于测试和反馈,因为它们的功能或设计可能会在版本之间发生变化而不发出警告,或者可能在未来的版本中完全删除。
描述
该docker manifest
命令本身不执行任何操作。为了对清单或清单列表进行操作,必须使用子命令之一。
单个清单是有关图像的信息,例如层、大小和摘要。该docker manifest
命令还为您提供其他信息,例如构建映像所针对的操作系统和体系结构。
清单列表是通过指定一个或多个(最好是多个)图像名称创建的图像层列表。例如,它可以像图像名称一样在命令中使用docker pull
。docker run
理想情况下,清单列表是从针对不同操作系统/体系结构组合功能相同的映像创建的。因此,清单列表通常被称为“多架构图像”。但是,用户可以创建一个指向两个映像的清单列表 - 一个用于 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
清单创建
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
明显注释
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
使用不安全的注册表
清单命令仅与注册表交互。因此,它无法向引擎查询允许的不安全注册表列表。为了允许 CLI 与不安全的注册表交互,某些docker manifest
命令有一个--insecure
标志。对于每个事务,例如create
查询注册表的事务,--insecure
必须指定该标志。此标志告诉 CLI 此注册表调用可能会忽略安全问题,例如丢失或自签名证书。同样,对于manifest push
不安全的注册表,--insecure
必须指定该标志。如果未将其与不安全的注册表一起使用,则清单命令将无法找到满足默认要求的注册表。
例子
检查图像的清单对象
$ 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)以及体系结构和操作系统(平台)。
就像其他采用镜像名称的 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
不需要该标志来注释清单列表,因为注释是针对清单列表的本地存储的副本。如果您正在 本地存储的清单列表上--insecure
执行操作,您也可以跳过该标志。docker manifest inspect
请务必记住,本地存储的清单列表永远不会被docker pull
.
子命令
命令 | 描述 |
---|---|
docker manifest annotate | 将附加信息添加到本地图像清单 |
docker manifest create | 创建本地清单列表以进行注释并推送到注册表 |
docker manifest inspect | 显示图像清单或清单列表 |
docker manifest push | 将清单列表推送到存储库 |
docker manifest rm | 从本地存储中删除一个或多个清单列表 |