I am going through a books and came across this line:
Whereas a tag can only be applied to a single image in a repository, a single image can have several tags. For example, the Java repository on Docker Hub maintains the following tags: 7, 7-jdk, 7u71, 7u71-jdk, openjdk-7, and openjdk-7u71. All these tags are applied to the same image.
My question is: why will a single image have several tags? What is the purpose of tagging the same image with different tags?
In my opinion there are mainly two reasons.
First of all, it is for convenience, so you may give multiple aliases to the same images.
But you can give other (special) tags to images in order to push it to a different registry.
Suppose (for example) you are using microk8s and you enabled the registry service. To push a local image of yours, you have to apply it with a tag formerly named
localhost:32000/my-image:my-tag
.In that scenario your image will have two tags
my-image:my-tag
andlocalhost:32000/my-image:my-tag
. So, to push it to microk8s registry the only thing you will have to do is to issue the commandgit push localhost:32000/my-image:my-tag
(the image tag will be parsed to get the URI of the registry to push to).The above concept, obviously, can be applied to any other remote registry.