Docker映像的映像ID与摘要之间有什么区别? [英] What's the difference between a Docker image's Image ID and its Digest?
问题描述
这真使我感到困惑.我以为Docker的映像ID是其SHA256哈希.但是,显然 docker image ls --digests
(列在标题 DIGEST
下列出)的结果与该图像的 IMAGE ID
不同
This has been surprisingly confusing for me. I thought Docker's Image ID is its SHA256 hash. However, apparently the result from docker image ls --digests
(listed under the column header DIGEST
) is different from the IMAGE ID
of that image.
例如
docker image ls --digests alpine
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
alpine latest sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6 055936d39205 2 weeks ago 5.53MB
同时
docker image ls --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE
...
alpine latest sha256:055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1 2 weeks ago 5.53MB
清楚地 sha256:055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1
(IMAGE ID)和 sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6ada464(6)但为什么?具有相同图像的两个不同的
sha256
哈希的目的是什么.分别如何计算?
Clearly sha256:055936d3920576da37aa9bc460d70c5f212028bda1c08c0879aedf03d7a66ea1
(IMAGE ID) and sha256:769fddc7cc2f0a1c35abb2f91432e8beecf83916c421420e6a6da9f8975464b6
(DIGEST) are not the same value. But why? What's the purpose of having two different sha256
hashes of the same image. How are they calculated, respectively?
在阅读《 Docker Deep Dive》一书时,我对此感到困惑,无论是在书中还是在线上,我都找不到清晰的答案.
I was confused by this when reading the book Docker Deep Dive, and I haven't been able to find a clear answer either in the book or online.
推荐答案
感谢michalk的评论.简短的答案是:
Thanks for michalk's comment. The short answer is:
- 摘要"是清单的哈希,在Docker注册表v2中引入.
- 图像ID是本地图像JSON配置的哈希值.
这篇关于Docker映像的映像ID与摘要之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!