skip to Main Content

Say I have this as part of a gitlab build pipeline:

- docker build -t ${CI_REGISTRY_IMAGE}/myimage:latest -t ${CI_REGISTRY_IMAGE}/myimage:$CI_VERSION .
- docker push --all-tags ${CI_REGISTRY_IMAGE}/myimage

Now I don’t really understand what is happening here in terms of tagging. Will the latest-tag be applied to every image that is pushed into the container registry, so multiple images have this tag? Or will the container registry make sure that there’s only one latest tag available which will refer to the latest container image that has been pushed.

Also, why is everyone speaking about "pushing tags" when in reality you are pushing container images? What happens if I push only one tag of a certain image and not the other, will the image be pushed with one tag only?

2

Answers


  1. Let’s say with the first command you create these two tags:

    latest
    1.0.0
    

    These are just names that refer to the id of the image that you just created e.g. 0e5574283393

    When you’re pushing a tag you are pushing this name and updating the image id that belongs to this name (e.g. latest) on the registry. If this image id does not exist in the registry the image is also pushed.

    If later you build a new image with the same command you maybe create:

    latest
    1.0.1
    

    Now you will have the following tags refering to the image id’s:

    tag image id
    latest 0e342283393
    1.0.1 0e342283393
    1.0.0 0e5574283393

    So latest is just the name that should refer to the image that was built last, but in reality you could put any image behind this name

    Login or Signup to reply.
  2. docker build -t ${CI_REGISTRY_IMAGE}/myimage:latest -t ${CI_REGISTRY_IMAGE}/myimage:$CI_VERSION .
    

    The order of operations:

    1. The image has been built.
    2. An ID (e.g. 6f6bf51237c5) has been assigned to this image.
    3. ${CI_REGISTRY_IMAGE}/myimage:latest is bound to the assigned ID.
    4. ${CI_REGISTRY_IMAGE}/myimage:$CI_VERSION is bound to the assigned ID.

    When people talk about "pushing tags," they refer to pushing the Docker images and their associated tags to a container registry. In Docker, tags are pointers to specific images. So, when you push a tag, you essentially push the corresponding image (and tag, too, with reference to this image) to the registry.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search