Is it possible for image to have multiple tags?

user606521 picture user606521 · Aug 12, 2015 · Viewed 52.5k times · Source

When I am pushing new image to repo I would like it to have two tags for example 0.2 and latest. This would allow to always pull latest image version by using latest tag and a specific version by using 0.2 tag for example. Is it possible with docker?

Is there any workaround? The only solution I see is to make two separate pushes...

Answer

Peterino picture Peterino · Jul 5, 2019

You can build an image with several tags and then push the image with the --all-tags option.

Example:

docker build -t reg/user/image:foo -t reg/user/image:latest .

docker push reg/user/image --all-tags

Older Docker clients that do not support --all-tags will push all tags by default (simply omit the option), newer clients will only push latest by default. As an alternative, you may want to push each tag separately.