zalando-stups / pierone

STUPS' Docker registry with S3 backend, immutable tags and SCM source tracking
http://docs.stups.io/en/latest/components/pierone.html
Other
57 stars 7 forks source link

Support docker pulling by sha256 #125

Closed dryewo closed 7 years ago

dryewo commented 7 years ago

By the official docker image registry it is supported:

$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest
$ docker rmi hello-world

$ docker pull hello-world@sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9: Pulling from library/hello-world
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world@sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9

From the API perspective, it's implemented by the same endpoint:

GET /v2/library/hello-world/manifests/latest
GET /v2/library/hello-world/manifests/sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9

This feature is required by Concourse CI's docker-image-resource together with latest tag support.

This digest is actually a SHA256 hash of the pretty-printed manifest JSON. In order to support it in Pier One we will need to store this hash in the tags table to allow fast lookups. This hash is already calculated on the fly and returned as Docker-Content-Digest header by many API endpoints in Pier One, so implementation should be easy.