docker注册表v2 API端点是为了获取图像的摘要? [英] What is the docker registry v2 API endpoint to get the digest for an image?

查看:121
本文介绍了docker注册表v2 API端点是为了获取图像的摘要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 https://docs.docker.com/registry/spec/api/ 我可以调用 / v2 /< name> / tags / list 来获取给定图像的标签列表。它可以正常工作,例如:

  {name=>avi / test,tags=& 最新]} 

但是,我想要每个标签的摘要。是的,摘要实际上是清单的哈希(至少从我最好的了解它,而不是100%清除)。但是,我想知道最新(和其他标签)的唯一标识符。



使用案例:我可能会有人将版本标记为最新版本,并希望检查该版本是否为最新:



$ pre> docker push avi / test:2.6
docker tag avi / test:2.6 avi / test:latest
docker push avi / test:latest
#build 2.7
docker push avi / test:2.7
#oops!忘记标签最新到2.7

在上述情况下,如果我不仅可以检查标签 - 哪些会给我2.6,2.7,最新 - 而且摘要(至少是清单),我可以找到各种标签指向,审核等。

解决方案

AFAIK,没有摘要API。但是,根据 v2 API规范,您可以执行 HEAD GET 请求反对 / v2 /< name> / manifestests /< reference> / code>。响应将包含一个 Docker-Content-Digest 头,其中包含指定清单的摘要(例如最新)。 / p>

According to https://docs.docker.com/registry/spec/api/ I can call /v2/<name>/tags/list to get a list of the tags for a given image. It works fine, e.g.:

{"name"=>"avi/test", "tags"=>["latest"]}

However, I would like the digest for each tag. Yes, the "digest" is actually the hash of the manifest (at least as I best understood it from the API; not 100% clear). However, I would like a way of knowing what a unique identifier for "latest" (and every other tag) is.

Use case: I might have someone tag a version as latest, and want to check the tit is up to date:

docker push avi/test:2.6
docker tag avi/test:2.6 avi/test:latest
docker push avi/test:latest
# build 2.7
docker push avi/test:2.7
# oops! Forgot to tag latest to 2.7

In the above case, if I can check not just the tags - which will give me "2.6", "2.7", "latest" - but also the digest (at least of the manifest), I can find what various tags point to, audit, etc.

解决方案

AFAIK, there isn't a digest API. However, according to the v2 API spec you can do a HEAD or GET request against /v2/<name>/manifests/<reference>. The response will include a Docker-Content-Digest header containing the digest of the specified manifest (e.g. latest).

这篇关于docker注册表v2 API端点是为了获取图像的摘要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆