指定 SHA 时如何使用多架构基础 docker 映像

Wil*_*don 3 sha docker dockerfile

我一直遵循我们的内部程序,该程序需要将 docker 基本映像固定到特定的 SHA。而且,我需要为 x86_64 和 ARM 构建多架构映像。

我正在查看的基本映像对于每个架构都有一个 SHA(我希望这完全有意义)。那么,如果生成的图像也应该是多架构的,我该如何指定特定的SHA ?我是否被每个拱门都使用了一个?FROMDockerfile

BMi*_*tch 5

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
Run Code Online (Sandbox Code Playgroud)