Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible for image to have multiple tags?

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...

like image 799
user606521 Avatar asked Aug 12 '15 11:08

user606521


People also ask

Can Docker images have multiple tags?

In Docker, we can also assign multiple tags to an image. Here, we'll use the docker build command to assign multiple tags to an image in a single command.

Does Docker push push all tags?

Use the -a (or --all-tags ) option to push all tags of a local image. The following example creates multiple tags for an image, and pushes all those tags to Docker Hub.

How do I tag a Docker image?

Building an Image When we use the Docker build command to build an image from a Dockerfile, we use the -t option to give a name and tag to the image.


1 Answers

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.

like image 90
Peterino Avatar answered Nov 12 '22 17:11

Peterino