docker manifest
描述 | 管理 Docker 镜像清单和清单列表 |
---|---|
用法 | docker manifest 命令 |
实验性功能
此命令为实验性功能。
实验性功能旨在用于测试和反馈,其功能或设计可能会在版本之间发生更改,恕不另行通知,也可能在将来的版本中完全移除。
描述
docker manifest
命令本身不执行任何操作。为了对清单或清单列表进行操作,必须使用其中一个子命令。
单个清单是关于镜像的信息,例如层、大小和摘要。docker manifest
命令还会提供其他信息,例如镜像构建的 OS 和架构。
清单列表是由一个或多个(理想情况下多于一个)镜像名称指定的镜像层列表。例如,它可以在 docker pull
和 docker run
命令中像镜像名称一样使用。
理想情况下,清单列表是从功能上相同的不同 os/arch 组合的镜像创建的。因此,清单列表通常被称为“多架构镜像”。但是,用户可以创建一个清单列表,该列表指向两个镜像——一个用于 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"
}
]
}
检查镜像的清单并获取 os/arch 信息
docker manifest inspect
命令采用可选的 --verbose
标志,该标志会提供镜像的名称(Ref)以及架构和 OS(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"
}
}
创建和推送清单列表
要创建清单列表,首先通过指定要包含在清单列表中的组成镜像来在本地创建
清单列表。请记住,这会推送到注册表,因此,如果要推送到 docker 注册表以外的注册表,则需要使用注册表名称或 IP 和端口创建清单列表。这类似于标记镜像并将其推送到外部注册表。
创建清单列表的本地副本后,您可以选择对其进行注释
。允许的注释包括架构和操作系统(覆盖镜像的当前值)、操作系统功能和架构变体。
最后,需要将清单列表推送
到所需的注册表。以下是这三个命令的描述,以及将它们组合在一起的示例。
$ 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 | 从本地存储删除一个或多个清单列表 |