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

标签 docker dockerfile sha

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

I'm looking at 的基础镜像每个架构都有一个 SHA(我希望这是完全合理的)。那么,如果生成的镜像也应该是多架构的,我如何在FROM中指定特定 SHA?我是否一直在为每个拱门使用 Dockerfile ??

最佳答案

Docker Hub 不会在网页上显示它,但多平台镜像的 list 列表有自己的摘要,这就是您想要提供给工具的内容。有多种工具可以实现这一点。我自己的工具是带有 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

关于docker - 指定 SHA 时如何使用多架构基础 docker 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74761737/

相关文章:

bash - 如何使用 docker 容器运行 nginx?

laravel - Dockerize Laravel流明

docker - 如何减少构建上下文

php - 如何在Docker镜像上启动服务?

security - SHA1可以解密吗

docker - 如何逐层调试docker pull?

ruby-on-rails - 无法访问 Assets - dockerized Rails 应用程序,nginx 作为反向代理

java - 如果我散列 IV 值,是否有任何安全改进?

docker - 如何优化 docker pull 速度

git - 获取tig提交的sha数