5

We store docker images in gitlab container registry. The images have tags such as imagename-datetimestamp.So if an image A is built at 8 a.m on 5/21/21, it is uploaded as imagenameA-0521210800. The next one built at 12 p.m is uploaded as imagenameA-0521211200. Is there an api or command that can help me fetch the last uploaded image at any time? In this case "imagenameA-0521211200" is the last uploaded.

Note: I do not want to pull with "latest" tag.

Thanks

user1164061
  • 4,222
  • 13
  • 48
  • 74
  • 1
    I presume you've tried this [List Registry Repository Tags](https://docs.gitlab.com/ee/api/container_registry.html#list-registry-repository-tags)? It's hard to write a full answer without knowing your environment, but using that to get the tags and then reading the JSON should be relatively straightforward, if that's what you're looking for. – bfren May 26 '21 at 17:40

1 Answers1

3

I suggest you to use the API to get your images tags list as per the example at https://docs.docker.com/registry/spec/api/#tags .

Then parse the result (eg. by jq), sort results and invokedocker pull for the right tag.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74