Search code examples
dockertagspush

Docker push: push image once with multiple 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?


Solution

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