Can I get an image digest without downloading the image?

前端 未结 6 520
执念已碎
执念已碎 2021-02-01 09:00

Similar to the question \"What´s the sha256 code of a docker image?\", I would like to find the digest of a Docker image. I can see the digest when I download an image:

6条回答
  •  半阙折子戏
    2021-02-01 09:39

    Following up on ByteFlinger's suggestion, which did not have an example, I tried this, and this is how to calculate it:

    $ docker-ls tag -registry https://myregistry.net:5000 
    spicysomtam/zookeeper:latest
    requesting manifest . done
    repository: spicysomtam/zookeeper
    tagName: latest
    digest: sha256:bd5dd80253171e4dffccbea7c639c90a63d5424aa2d7fe655aea766405c83036
    
    $ curl -ns -H "Accept: 
    application/vnd.docker.distribution.manifest.v2+json" -X GET  
    https://myregistry.net:5000/v2/spicysomtam/zookeeper/manifests/latest|sha256sum
    bd5dd80253171e4dffccbea7c639c90a63d5424aa2d7fe655aea766405c83036  -
    
    $ docker images --digests |grep zookeeper
    myregistry.net:5000/spicysomtam/zookeeper           latest                                     sha256:bd5dd80253171e4dffccbea7c639c90a63d5424aa2d7fe655aea766405c83036   a983e71ca22d        29 hours ago        584MB
    

提交回复
热议问题