1

I would like to get the images and image ids of a number of docker images (over 100+). I can't pull all these images on my local machine to fetch the image ids. Is there a way using docker api or python gitlab api this would be possible to do? I was alternately thinking of using requests to achieve this. Would really appreciate if anyone could share their insights on how to accomplish this.

# code so far
import docker
cli = docker.from_env()
cl_image = None
cli.login(username='<username>', password='<password>', registry='<registry-url-here>')
cl_image = cli.images.get('<enter registry url>/<image_name>:<image_tag>')
print(cl_image.id)

Unless I have the image pulled, I get an error: no such image! I see this useful link, https://docs.gitlab.com/ee/api/container_registry.html but unsure how to use this. Is this the way to go about obtaining the image details?

Thanks for the help.

py_noob
  • 433
  • 2
  • 8
  • 17
  • 1
    Have you tried using `get_registry_data(name, auth_config=None)` from `client.images` api? – Algebra8 Aug 21 '20 at 18:10
  • 1
    @Algebra8, yes that worked, thank you so much!! Made my job so much simpler. – py_noob Aug 21 '20 at 18:56
  • @Algebra8 - How can I check the credentials in auth_config? I have currently set it to `None` and I had no issues so far but I recently changed my gitlab login password and I see an issue with gitlab login through my python script. – py_noob Oct 05 '20 at 18:41

0 Answers0