cli icon indicating copy to clipboard operation
cli copied to clipboard

Allow `docker push' to push multiple/a subset of tags

Open ebd2 opened this issue 8 years ago • 62 comments

Allow the following usage:

docker push org/image-a:some_tag org/image-b:other_tag

This would make docker push simpler to use in systems that need to build and push multiple images to dockerhub by obviating the need to wrap docker push in a loop.

ebd2 avatar Jun 29 '17 14:06 ebd2

@dnephin, super cool tool! imma try it out. for my educational purposes, i'm going to implement this feature. :)

glyif avatar Aug 11 '17 00:08 glyif

Also it can save resources while building - the same image does not have to be uploaded twice.

iBobik avatar Nov 15 '17 12:11 iBobik

Prior discussions on this feature can be found in https://github.com/moby/moby/issues/7336, https://github.com/moby/moby/pull/11682, https://github.com/moby/moby/issues/16106, and related, https://github.com/moby/moby/issues/23383

Note that adding support for this on the command-line will not provide enhancements other than not having to "loop" through tags for pushing (see https://github.com/docker/cli/pull/458#pullrequestreview-57642310)

thaJeztah avatar Nov 15 '17 13:11 thaJeztah

I wonder how that ticket is still open. it started in 2014.. was a quest to finally find the last instance here :) Anyway. Im in for it.

SeidChr avatar Nov 25 '17 18:11 SeidChr

I wonder how that ticket is still open. it started in 2014.. was a quest to finally find the last instance here :) Anyway. Im in for it.

+1

It's curious/weird how you can tag multiple tags at once with docker build -t, but you can't publish them all at once...

elboletaire avatar Dec 18 '17 15:12 elboletaire

Guys what the progress on this issue? Still need docker push with multiple tags!

Hronom avatar Dec 22 '17 11:12 Hronom

This, please!

Nowaker avatar Jan 17 '18 22:01 Nowaker

+1

smuryginim avatar Mar 05 '18 10:03 smuryginim

+1

XBeg9 avatar Apr 05 '18 18:04 XBeg9

How is this still a thing?

pappnase99 avatar Apr 13 '18 16:04 pappnase99

There's currently the PR https://github.com/docker/cli/pull/458#pullrequestreview-57642310 which is under review. AFAIK for now it only adds a loop for the docker push instead of trying to do it in parallel, which is how it works in docker build; that's why it isn't still accepted.

elboletaire avatar Apr 14 '18 11:04 elboletaire

Oh its open. I though its already implemented :(

ggalihpp avatar Jul 06 '18 03:07 ggalihpp

Ignoring the performance, the options either to push image with all tags or single tag seems bit odd.

AntonKrug avatar Jul 19 '18 13:07 AntonKrug

You can install dokr . and use dokr dock --push image_name. This will push your multiple images

javatechy avatar Sep 26 '18 04:09 javatechy

Please do this at least, so many time since this started, I was thinking it's already implemented.

Hronom avatar Sep 26 '18 07:09 Hronom

+1

aramhakobyan avatar Oct 29 '18 10:10 aramhakobyan

This is more of a design problem. I'd blindly assumed that this would have worked for me

$ docker push $(docker images --format "{{.Repository}}" | grep "foobar")

only to realize it takes just one argument. I'd say the same for docker pull. There are just too many great use cases for a multi-push. Plus, it's pretty neat instead of a

$ for i in `docker images --format "{{.Repository}}" | grep "foobar"; do docker push $i; done

Not very command-like.

achillesrasquinha avatar Dec 07 '18 20:12 achillesrasquinha

@achillesrasquinha

Is it not necessary pass the tag?

Example:

docker images --format "{{.Repository}}:{{.Tag}}" | grep "foobar"
lagden/foobar:6.1.0
lagden/foobar:latest

lagden avatar Jan 10 '19 08:01 lagden

I was able to do this using AWS ECR for our docker image hosting. We're using jenkins for CI to push the image up to ECR once the build is finished. Then you can use aws cli to re-tag the image with whatever you want, including variables.

In this example, push your initial image up with the latest tag, then specify whatever additional tag you'd like in the second command behind --image-tag

MANIFEST=\$(aws ecr batch-get-image --repository-name yeet --image-ids imageTag=latest --query 'images[].imageManifest' --output text)

aws ecr put-image --repository-name yeet --image-tag v_$BUILD_NUMBER --image-manifest "\$MANIFEST"

We're using ECS for hosting so this actually fit nicely into our pipe. You can still use amazon ECR if you're hosting elsewhere though.

purplesoda avatar Jan 14 '19 17:01 purplesoda

Any new?!

thiagolsfortunato avatar Jun 07 '19 16:06 thiagolsfortunato

I achieve this by using pipes with echo and xargs, but it really needs to be implemented, this only automate it, but the command is summoned each time.

If anyone wondering: echo 'repo/flavor:tag' 'repo/flavor:tag' 'repo/flavor:tag' | xargs -n 1 docker push

davidtabernerom avatar Jul 12 '19 22:07 davidtabernerom

Any news on this?

saravana1992 avatar Sep 15 '19 05:09 saravana1992

Abandon hope all ye who enter here.

I've had great success using skopeo which allows flexible manipulation of remote docker image registries, like re-tagging images on remotes without needing to push/pull locally, or pushing/pulling multiple images in parallel, etc.

sj26 avatar Sep 15 '19 05:09 sj26

@davidtabernerom 's workaround fixes it :) But hopefully this gets implemented in future

FearlessHyena avatar Sep 18 '19 01:09 FearlessHyena

The problem with the workaround is you can't say "push exactly this version of this image to these tags on the remote" — if you have multiple processes or threads on a machine then they can stomp on the local tags before, while, or after each push to the remote, so you may get tags on the remote which point to different images. :-(

sj26 avatar Sep 18 '19 02:09 sj26

To avoid unnecessary repetitions, use this Bash expansion syntax:

echo repo/flavor:{1.0.0,1.2.3} | xargs -n 1 docker push
# or
echo repo/{foo,bar}:1.2.3 | xargs -n 1 docker push
# or even
echo repo/{foo,bar}:{1.0.0,1.2.3} | xargs -n 1 docker push

adampl avatar Nov 29 '19 14:11 adampl

I solved the problem by the following: docker push [REPOSITORY]

example: localhost:5000/someRepo:tag1 localhost:5000/someRepo:tag2 localhost:5000/someRepo:tag3

The following will push all the above example images to the REPOSITORY docker push localhost:5000/someRepo

As a result tag1, tag2, and tag3 will be pushed to the REPO "localhost:5000/someRepo" recursively.

msbenjamin12 avatar Jan 14 '20 23:01 msbenjamin12

I solved the problem by the following: docker push [REPOSITORY]

example: localhost:5000/someRepo:tag1 localhost:5000/someRepo:tag2 localhost:5000/someRepo:tag3

The following will push all the above example images to the REPOSITORY docker push localhost:5000/someRepo

As a result tag1, tag2, and tag3 will be pushed to the REPO "localhost:5000/someRepo" recursively.

Thanks! This works perfectly in our build environment.

dbartokthomas avatar Jan 15 '20 13:01 dbartokthomas

With the solution of @msbenjamin12 this issue seems resolved.

WebSpider avatar Mar 02 '20 16:03 WebSpider

No, that pushes ALL tags for a repository. For us at least we want to be able to push multiple specific tags, but not just blanket push the entire repo.

superstator avatar Mar 02 '20 16:03 superstator