Read out label of remote/local image with python

Hi!

I’m working on a python script to pull a newer version from a docker image. However I’m struggling to figure out how I can read out the label/version of the local imagine and the remote one.
I was looking through the documentation of the API but couldn’t find anything helpful.

Do you guys have any ideas?
Thanks in advance?

Julius

If anyone has an idea I would really appreciate your help!

I started to reply some days ago, but then I stopped, becasue I don’t use the Python SDK so I am not the best person to help here, but I will try.

I am not sure about the remote image, because that would require a Docker Registry API, but reading the label of a local image, seems simple:

https://docker-py.readthedocs.io/en/stable/images.html#image-objects

You probably know the SDK better then me, so I hope the link to the image object reference can help.

If you want to read the remote image’s label, I don’t know better way then pulling the image and reading it locally. Of course, then you would override the local image, unless you are doing it in a Docker in Docker environment.

You could use an other tool like:

or try to figure out how you could get the same data using the registry API:

Unfortunately I don’t know if there is an existing SDK that you can use in Python.