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
Let’s say with the first command you create these two tags:
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:
Now you will have the following tags refering to the image id’s:
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 nameThe order of operations:
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.