gpt4 book ai didi

docker - 为什么两个 docker 镜像具有相同的镜像 ID 和相同的标签,但摘要不同?

转载 作者:行者123 更新时间:2023-12-05 06:19:12 26 4
gpt4 key购买 nike

当我 docker pull hello-world 时,我得到了摘要为 f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e 的图像

$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Image is up to date for hello-world:latest
docker.io/library/hello-world:latest

我使用的是 Mac,但是当我 docker inspect hello-world:latest 时,我看到 os/arch 是 linux/amd64

    ...
"Architecture": "amd64",
"Os": "linux",
...

所以我去了https://hub.docker.com/_/hello-world/?tab=tags奇怪的是,linux/amd64 的最新 hello-world 位于 https://hub.docker.com/layers/hello-world/library/hello-world/latest/images/sha256-92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a?context=explore摘要为 92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a

所以我也拉下了这张图

$ docker pull hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a: Pulling from library/hello-world
Digest: sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
Status: Downloaded newer image for hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
docker.io/library/hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a

令人惊讶的是,我最终得到了两张标签相同、图像 ID 相同但摘要不同的图像。

$ docker image ls --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
hello-world latest sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a fce289e99eb9 15 months ago 1.84kB
hello-world latest sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e fce289e99eb9 15 months ago 1.84kB

这两张图片是同一张吗?如果我希望在我的团队中保持一致,我该如何唯一地处理图像?

最佳答案

hello-world 图像是一个多平台图像。每个平台都包含自己的 list ,并且有一个指向所有平台的 list 列表。这些 list 和 list 列表中的每一个都有自己的摘要。在您的列表中,docker 显示了 list 列表的摘要,以及您的特定平台 list 的摘要:

$ docker buildx imagetools inspect hello-world@sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Name: docker.io/library/hello-world@sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
MediaType: application/vnd.docker.distribution.manifest.list.v2+json
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e

Manifests:
Name: docker.io/library/hello-world@sha256:92c7f9c92844bbbb5d0a101b22f7c2a7949e40f8ea90c8b3bc396879d95e899a
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/amd64

Name: docker.io/library/hello-world@sha256:e5785cb0c62cebbed4965129bae371f0589cadd6d84798fb58c2c5f9e237efd9
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/arm/v5

Name: docker.io/library/hello-world@sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/arm/v7

Name: docker.io/library/hello-world@sha256:963612c5503f3f1674f315c67089dee577d8cc6afc18565e0b4183ae355fb343
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/arm64/v8

Name: docker.io/library/hello-world@sha256:85dc5fbe16214366748ebe9d7cc73bc42d61d19d61fe05f01e317d278c2287ed
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/386

Name: docker.io/library/hello-world@sha256:8aaea2a718a29334caeaf225716284ce29dc17418edba98dbe6dafea5afcda16
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/ppc64le

Name: docker.io/library/hello-world@sha256:577ad4331d4fac91807308da99ecc107dcc6b2254bc4c7166325fd01113bea2a
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: linux/s390x

Name: docker.io/library/hello-world@sha256:468a2702c410d84e275ed28dd0f46353d57d5a17f177aa7c27c2921e9ef9cd0e
MediaType: application/vnd.docker.distribution.manifest.v2+json
Platform: windows/amd64
OSVersion: 10.0.17763.1098

关于docker - 为什么两个 docker 镜像具有相同的镜像 ID 和相同的标签,但摘要不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60896860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com