docker - Can I get an image digest without downloading the image? -
similar question "what´s sha256 code of docker image?", find digest of docker image. can see digest when download image:
$ docker pull waisbrot/wait:latest latest: pulling waisbrot/wait digest: sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330 status: image date waisbrot/wait:latest $
another question, what docker registry v2 api endpoint digest image has answer suggesting docker-content-digest
header.
i can see there docker-content-digest
header when fetch manifest image:
$ curl 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:waisbrot/wait:pull' -h "authorization: basic ${username_password_base64}" # store 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 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 > /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
however, header isn't same. pull
command got me 6f21
, header shows 128c
. further, pull command doesn't work digest:
$ docker pull waisbrot/wait@sha256:128c6e3534b842a2eec139999b8ce8aa9a2af9907e2b9269550809d18cd832a3 error response daemon: manifest unknown: manifest unknown
whereas things work want when have correct digest:
$ docker pull waisbrot/wait@sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330 12:46 waisbrot@influenza sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330: pulling waisbrot/wait digest: sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330 status: image date waisbrot/wait@sha256:6f2185daa4ab1711181c30d03f565508e8e978ebd0f263030e7de98deee5f330
what i'm looking way translate latest
tag (which changes time) fixed digest can reliably pull. don't want pull down in order translation.
try
$ 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}"
background: this forum link discussing same issue.
the problem default content-type being selected server application/vnd.docker.distribution.manifest.v1+prettyjws
(a v1 manifest) , need v2 manifest. therefore, need set accept
header application/vnd.docker.distribution.manifest.v2+json
.
Comments
Post a Comment