为什么我新创建的docker没有摘要? [英] Why doesn't my newly-created docker have a digest?
问题描述
我一直在关注此处的Docker教程,并且通过将更改提交到现有映像并使用三个不同的标签对其进行标记,在本地OSX计算机上构建了一个测试映像:
I have been following the Docker tutorial here, and built a test image on my local OSX machine by committing changes to an existing image and tagging it with three different labels:
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
adamatan/sinatra devel fccb6b4d21b4 8 minutes ago 469.5 MB
adamatan/sinatra junk fccb6b4d21b4 8 minutes ago 469.5 MB
adamatan/sinatra latest fccb6b4d21b4 8 minutes ago 469.5 MB
但是,这些图像都没有摘要:
However, none of these images has a digest:
# docker images --digests adamatan/sinatra
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
adamatan/sinatra devel <none> fccb6b4d21b4 9 minutes ago 469.5 MB
adamatan/sinatra junk <none> fccb6b4d21b4 9 minutes ago 469.5 MB
adamatan/sinatra latest <none> fccb6b4d21b4 9 minutes ago 469.5 MB
我用Dockerfile创建的其他测试映像确实有摘要.
Other test images I have created with a Dockerfile do have a digest.
为什么有些图像有摘要,而有些则没有?与映像的创建方式(是否为Dockerfile)有关吗?
推荐答案
首先,请记住,摘要可以表示manifest
,层或它们的组合(我们通常将该组合称为图像).
Firstly, Please keep in mind that a digest could represent a manifest
, a layer or a combination of them (we normally called that combination an image).
Manifest
是Docker注册表V2引入的新术语.以下是从 Docker Registry V2幻灯片第21页至第23页获取的简短说明:>
Manifest
is a new term that introduced with Docker registry V2. Here is a short description fetched from Docker Registry V2 slides page21 ~ page23:
- [清单]描述单个对象中图像的组成部分
- 可以立即并行获取层.
- [Manifest] describes the components of an image in a single object
- Layers can be fetched immediately, in parallel.
使用命令docker images --digests
获取摘要时,此处的摘要是图像清单的SHA256哈希,但是图像ID是本地图像JSON配置的哈希码(此配置与清单不同).在这种情况下,如果图像没有关联的清单,则该图像的摘要将为无".
When you get the digests with command docker images --digests
, here the digest is the SHA256 hash of image manifest, but image ID is the hash code of the local image JSON configuration (this configuration is different from manifest). In this case, if an image doesn't have an associated manifest, the digest of that image will be "none".
通常,两种情况可能会使图像没有关联的清单:
Normally, two scenarios could make an image doesn't have associated manifest:
- 此映像尚未推送到V2注册表或从V2注册表中拉出.
- 此图片已从V1注册表中提取.
要生成清单,最简单的方法是将映像推送到V2注册表(V1注册表将不起作用). Docker客户端将在本地生成清单,然后将其与图像层一起推送到注册表.当您将图像拉回时,图像将具有清单.
To generate a manifest, the easiest way is to push the image to a V2 registry (V1 registry will not works). Docker client will generate a manifest locally, then push it with image layers to registry. When you pull the image back, the image will has a manifest.
清单一旦存在,您的图像摘要就不应为无".
Once the manifest existing, your image digest should not be "none".
这篇关于为什么我新创建的docker没有摘要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!