docker – 我可以在不下载图像的情况下获得图像摘要吗?

前端之家收集整理的这篇文章主要介绍了docker – 我可以在不下载图像的情况下获得图像摘要吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

与问题“What´s the sha256 code of a docker image?”类似,我想找到Docker镜像的摘要.我下载图片时可以看到摘要

$docker pull waisbrot/wait:latest                                                                                                  
latest: Pulling from waisbrot/wait
Digest: sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330
Status: Image is up to date for waisbrot/wait:latest
$

另一个问题,What is the Docker registry v2 API endpoint to get the digest for an image有一个答案暗示Docker-Content-Digest标题.

当我获取图像的清单时,我可以看到有一个Docker-Content-Digest标头:

$curl 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:waisbrot/wait:pull' -H "Authorization: Basic ${username_password_base64}"

# store the resulting token in DT

$curl -v https://registry-1.docker.io/v2/waisbrot/wait/manifests/latest -H "Authorization: Bearer $DT" -XHEAD
*   Trying 52.7.141.30...
* Connected to registry-1.docker.io (52.7.141.30) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.docker.io
* Server certificate: RapidSSL SHA256 CA - G3
* Server certificate: GeoTrust Global CA
> GET /v2/waisbrot/wait/manifests/latest HTTP/1.1
> Host: registry-1.docker.io
> User-Agent: curl/7.43.0
> Accept: */*
> Authorization: Bearer LtVRw-etc-etc-etc
>
< HTTP/1.1 200 OK
< Content-Length: 4974
< Content-Type: application/vnd.docker.distribution.manifest.v1+prettyjws
< Docker-Content-Digest: sha256:128c6e3534b842a2eec139999b8ce8aa9a2af9907e2b9269550809d18cd832a3
< Docker-Distribution-Api-Version: registry/2.0
< Etag: "sha256:128c6e3534b842a2eec139999b8ce8aa9a2af9907e2b9269550809d18cd832a3"
< Date: Wed,07 Sep 2016 16:37:15 GMT
< Strict-Transport-Security: max-age=31536000

但是,这个标题是不一样的. pull命令让我6f21,标题显示128c.此外,pull命令不适用于该摘要

$docker pull waisbrot/wait@sha256:128c6e3534b842a2eec139999b8ce8aa9a2af9907e2b9269550809d18cd832a3                               
Error response from daemon: manifest unknown: manifest unknown

当我有正确的摘要时,事情就像我想要的那样工作:

$docker pull waisbrot/wait@sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330                                 12:46  waisbrot@influenza
sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330: Pulling from waisbrot/wait
Digest: sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330
Status: Image is up to date for waisbrot/wait@sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330

我正在寻找的是一种将最新标签(一直在变化)转换为可以可靠拉动的固定摘要方法.但是我不想实际将它拉下来进行翻译.

尝试

$curl -H "Accept: application/vnd.docker.distribution.manifest.v2+json" 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:waisbrot/wait:pull' -H "Authorization: Basic ${username_password_base64}"

背景:This forum link正在讨论同样的问题.

问题是服务器选择的默认内容类型是application / vnd.docker.distribution.manifest.v1 prettyjws(一个v1清单),你需要v2 manifest.因此,您需要将Accept标头设置为application / vnd.docker.distribution.manifest.v2 json.

原文链接:https://www.f2er.com/docker/436963.html

猜你在找的Docker相关文章