Search code examples
dockerdocker-registry

How to get a rolling latest tag in the docker registry


I'm trying to understand the docker registry and it's tagging.

I'm actually using the gitlab registry.

Scenario:

I push image1:latest

Five minutes later I push image1:latest again.

I only have one instance of image1:latest in my registry.

I'm guessing that a tag is just text with no semantic meaning which is understood. So the registry cannot keep only one image with the latest tag. It'd doesn't understand that latest means something.

What I need, if I am understanding this correctly, is a way to only have one image with the latest tag. So in my example above, I would see..

image1 - Uploaded 5 minutes ago

image1:latest - Uploaded 30 seconds ago

If it doesn't work this way then what is the correct versioning strategy for containers?


Solution

  • This article on medium will help clear up a lot of confusion.

    https://medium.com/@mccode/the-misunderstood-docker-tag-latest-af3babfd6375

    In my case, we typically version the number of our image builds, for example, tagging the image with image1:v_1, will create an image image1:v_1. What also happens is that image1:v_1 can also be referenced using image1:latest. So if you keep tagging image1 with image1:latest it doesn't really have a tag, it just knows that it's the latest. Hope that wasn't too confusing.