过去几天我一直在努力解决多架构清单注释。 我使用 buildah/podman 来创建图像,但我找不到如何将通用 org.opencontainers.image.description 注释添加到定义多架构图像的清单中的方法。
一般来说,我使用以下命令序列构建图像:
# Build all arch. images
#
buildah bud --platform linux/amd64 -f Dockerfile --format oci --tls-verify=true -t debian-gcc:gcc_bullseye-linuxamd64 /home/runner/work/docker-images/docker-images
buildah bud --platform linux/arm64 -f Dockerfile --format oci --tls-verify=true -t debian-gcc:gcc_bullseye-linuxarm64 /home/runner/work/docker-images/docker-images
# Create a manifest and add all arch. images there.
#
buildah manifest create debian-gcc:gcc_bullseye
buildah manifest add debian-gcc:gcc_bullseye debian-gcc:gcc_bullseye-linuxamd64
buildah manifest add debian-gcc:gcc_bullseye debian-gcc:gcc_bullseye-linuxarm64
# Inspect the manifest
#
podman manifest inspect debian-gcc:gcc_bullseye
清单包含以下内容:
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 500,
"digest": "sha256:7dbefc31c7b5f7c4f67f18f92213daec8c48740d9533996363812de4385b9528",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 500,
"digest": "sha256:968fc2d27179baa3e7f8c85c7657659c5c67807dcd002922edce1437d22645f9",
"platform": {
"architecture": "arm64",
"os": "linux"
}
}
]
}
我想为此清单添加注释,但到目前为止我总是失败。
预期结果是:
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 500,
"digest": "sha256:7dbefc31c7b5f7c4f67f18f92213daec8c48740d9533996363812de4385b9528",
"platform": {
"architecture": "amd64",
"os": "linux"
}
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"size": 500,
"digest": "sha256:968fc2d27179baa3e7f8c85c7657659c5c67807dcd002922edce1437d22645f9",
"platform": {
"architecture": "arm64",
"os": "linux"
}
}
],
"annotations": {
"org.opencontainers.image.description: "My description ..."
}
}
我尝试使用 buildah-manifest-annotate 但没有成功。
buildah manifest annotate --annotation org.opencontainers.image.description="My description ..." debian-gcc:gcc_bullseye debian-gcc:gcc_bullseye
我想说失败的主要原因是清单“vnd.oci.image.manifest.v1+json”不能包含每个规范的注释,但是索引“vnd.oci.image。 index.v1+json"可以。
这样做的动机是为 github 包或 quay 存储库中的多架构镜像提供正确的描述。
所以,总而言之,问题是如何使用
podman
或 buildah
来注释多拱形图像?
我感谢任何帮助我回到正轨的帮助。
在寻找同一问题的答案时发现了这个问题。我知道这个问题已经快一年了,但我能够弄清楚。
现在在 buildah v1.35.0 和 podman v5.0.0 中添加了
--annotation
和 buildah manifest create
的 podman manifest create
选项。请参阅https://docs.podman.io/en/v5.0.0/markdown/podman-manifest-create.1.html#annotation-value。您可以使用 --amend
将注释添加到现有清单。
在给定的示例中,您将使用:
buildah manifest create --annotation "org.opencontainers.image.description=My description ..." debian-gcc:gcc_bullseye