Getting image pull history using Registry API

845 Views Asked by At

I am trying to create a python script to see when was last time my image was pulled from a container registry. I went through Registry API under API Reference and tried the following APIs to get information:

To list repo:

GET /v2/_catalog

To pull an image manifest:

GET /v2/<name>/manifests/<reference>

To pull a layer:

GET /v2/<name>/blobs/<digest>

After pulling the layer I can see a lot of information including history but not when was the last time image:tag was pulled.

How can I fetch when was the last time my image:tag was pulled?

Will be great if someone can help me with the APIs.

Thanks

1

There are 1 best solutions below

2
On

The registry is a content addressable store. The digest from what was pushed is the same as the digest when you pull it, and that digest indicates the content of the image. Usage statistics therefore cannot be put into the image, since they would mutate what is being pulled.

Registries may provide separate APIs to give out usage statistics. Those will be custom to the registry because as of the date of this post, OCI has not standardized any API to fetch that metadata.

Looking at the GCR and GAR REST API docs, I'm not seeing any metadata details in there: