sha256 of a singularity image ??

193 views
Skip to first unread message

Edgar Garriga

unread,
Jun 5, 2018, 2:17:12 PM6/5/18
to singularity
Does the container has this metadata? 
Is stored somewhere the sha256 of the container inside it?? Is it possible to get this value without having to calculate it over and over??

In Docker we have : docker inspect --format='{{index .Id}}' $IMAGE


Thanks in advance!

v

unread,
Jun 5, 2018, 2:28:40 PM6/5/18
to singu...@lbl.gov
Hey Edgar,

I think I shared this with you on slack, but I'll put it here for the record because Slack doesn't have a paid plan, and so it eventually goes away :) If you download a container from Singularity Hub you can minimally get the metadata via the API: Here is an example:


An even better solution would be to pull with a feature that I added quite some time ago - you can request the container to be named by commit (Github) or version (the hash sum):


vanessa@vanessa-ThinkPad-T460s:~$ singularity pull --commit shub://vsoch/hello-world
Progress |===================================| 100.0% 
Done. Container is at: /home/vanessa/e279432e6d3962777bb7b5e8d54f30f4347d867e.simg     <-- Github commit
vanessa@vanessa-ThinkPad-T460s:~$ singularity pull --hash shub://vsoch/hello-world
Progress |===================================| 100.0% 
Done. Container is at: /home/vanessa/ed9755a0871f04db3e14971bec56a33f.simg                      <-- file hash

Shwoop! The latter is the better of the two approaches because the API operation (to get and name the image) is done in one call, and then you can keep the version with the image via the filename. Unfortunately this would only work with images on shub, but you could generate the version on your own if you build elsewhere. And of course as @godloved mentnioed, this will be available as metadata for singularity 3.0 at some point in the future.

Finally, another option is to use the Singularity Global Client (sregistry) tool that keeps versions of images as you add them to your little database, always:

$sregistry images
Containers:   [date]   [client] [uri]
1  May 16, 2018    [hub] vsoch/hello-world:latest@ed9755a0871f04db3e14971bec56a33f


$ sregistry inspect vsoch/hello-world
vsoch/hello-world
/home/vanessa/.singularity/shub/vsoch-hello-world:lat...@ed9755a0871f04db3e14971bec56a33f.simg
{
    "client": "hub",
    "collection": "vsoch",
    "collection_id": 1,
    "created_at": "2018-05-16 22:03:07",
    "id": 1,
    "image": "/home/vanessa/.singularity/shub/vsoch-hello-world:lat...@ed9755a0871f04db3e14971bec56a33f.simg",
    "metrics": {
        "collection": "vsoch",
        "image": "hello-world",
        "storage": "vsoch/hello-world:lat...@ed9755a0871f04db3e14971bec56a33f.simg",
        "tag": "latest",
        "uri": "vsoch/hello-world:latest@ed9755a0871f04db3e14971bec56a33f",
        "url": "vsoch/hello-world",
        "version": "ed9755a0871f04db3e14971bec56a33f"
    },
    "name": "hello-world",
    "tag": "latest",
    "uri": "vsoch/hello-world:latest@ed9755a0871f04db3e14971bec56a33f",
    "url": "https://www.googleapis.com/download/storage/v1/b/singularityhub/o/singularityhub%2Fgithub.com%2Fvsoch%2Fhello-world%2Fe279432e6d3962777bb7b5e8d54f30f4347d867e%2Fed9755a0871f04db3e14971bec56a33f%2Fed9755a0871f04db3e14971bec56a33f.simg?generation=1508072025589820&alt=media",
    "version": "ed9755a0871f04db3e14971bec56a33f"
}



Best,

V


--

You received this message because you are subscribed to the Google Groups "singularity" group.
To unsubscribe from this group and stop receiving emails from it, send an email to singularity+unsubscribe@lbl.gov.

--
Vanessa Villamia Sochat
Stanford University '16
Reply all
Reply to author
Forward
0 new messages