【问题标题】:How to use a multiarch base docker image when specifying SHA指定 SHA 时如何使用多架构基础 docker 镜像
【发布时间】:2022-12-12 04:48:36
【问题描述】:
我坚持遵循我们的内部程序需要将 docker 基础镜像固定到特定的 SHA。和,我一直需要为 x86_64 和 ARM 构建多架构映像。
I'm looking at 的基本图像对每个架构都有一个 SHA(我希望这完全有意义)。那么我怎样才能指定一个具体的FROM 中的 SHA 如果结果图像也应该是多架构的?我是否坚持为每个拱门使用 Dockerfile?
【问题讨论】:
标签:
docker
dockerfile
sha
【解决方案1】:
Docker Hub 不会在网页上显示它,但多平台映像的清单列表有其自己的摘要,这就是您想要提供给工具的内容。有多种工具可以做到这一点。我自己的工具是带有 regctl CLI 的 regclient,Google 的 go-containerregistry 有 crane,Docker 已经在 buildx 下包含了一个 imagetools CLI:
$ regctl image digest bitnami/minideb
sha256:713d1fbd2edbc7adf0959721ad360400cb39d6b680057f0b50599cba3a4db09f
$ crane digest bitnami/minideb
sha256:713d1fbd2edbc7adf0959721ad360400cb39d6b680057f0b50599cba3a4db09f
$ docker buildx imagetools inspect bitnami/minideb
Name: docker.io/bitnami/minideb:latest
MediaType: application/vnd.docker.distribution.manifest.list.v2+json
Digest: sha256:713d1fbd2edbc7adf0959721ad360400cb39d6b680057f0b50599cba3a4db09f
Manifests:
Name: docker.io/bitnami/minideb:latest@sha256:2abaa4a8ba2c3ec9ec3cb16a55820db8d968919f41439e1e8c86faca81c8674a
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/amd64
Name: docker.io/bitnami/minideb:latest@sha256:3c44390903734b2657728fcad8fb33dcdf311bdeaafcc3b9f179d78bdf4da669
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/arm64