Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker push: push image once with multiple tags

Tags:

docker

push

tags

I have a docker image with three tags repo:latest, repo:v1.1, repo:dev. When I do docker push repo:v1.1 only one tag will be pushed into repository. Is there a way to make one push with all tags or I need to push-per-tag?

like image 216
mtkachenko Avatar asked Dec 27 '18 13:12

mtkachenko


2 Answers

The docker push command does not accept several arguments (if ever one wants to push a selection of several tags (not all) in one go), so one needs to push each tag separately, e.g.:

for t in latest v1.1 dev; do
    docker push "repo:${t}"
done

Otherwise, as mentioned in @GuillaumePancak's answer, one may be interested in relying on the --all-tags flag available from Docker 20.10.0.

Note also that it is frequent to consider pushing several different tags for the same image (which may be your use case here as well). In this case pushing these tags successively (and not at the same time with several concurrent processes) ensures the docker push of the tag synonyms will be almost immediate, after the image has been pushed once with a given tag.

like image 185
ErikMD Avatar answered Sep 25 '22 02:09

ErikMD


If you want to push all tags for an image, you can use the --all-tags option:

docker image push --all-tags repository/image_name

This option is supported for Docker 20.10 and newer. The same behaviour can be achieved by omitting --all-tags on older versions.


More information: Docker push documentation

like image 25
Guillaume Pancak Avatar answered Sep 25 '22 02:09

Guillaume Pancak