Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement docker push -a/--all-tags #2220

Merged
merged 1 commit into from
Jan 30, 2020

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Dec 9, 2019

fixes #2214

depends on moby/moby#40302 client.ImagePush(): default to ":latest" instead of "all tags"

The docker push command up until v0.9.1
always pushed all tags of a given image, so docker push foo/bar would push (e.g.)
all of foo/bar:latest, foo:/bar:v1, foo/bar:v1.0.0.

Pushing all tags of an image was not desirable in many case, so docker v0.10.0
enhanced docker push to optionally specify a tag to push (docker push foo/bar:v1)
(see moby/moby#3411 and the pull request that implemented
this: moby/moby#4948).

This behavior exists up until today, and is confusing, because unlike other commands,
docker push does not default to use the :latest tag when omitted, but instead
makes it push "all tags of the image"

For example, in the following situation;

docker images

REPOSITORY          TAG                        IMAGE ID            CREATED             SIZE
thajeztah/myimage   latest                     b534869c81f0        41 hours ago        1.22MB

Running docker push thajeztah/myimage seemingly does the expected behavior (it
pushes thajeztah/myimage:latest to Docker Hub), however, it does not so for the
reason expected (:latest being the default tag), but because :latest happens
to be the only tag present for the thajeztah/myimage image.

If another tag exists for the image:

docker images

REPOSITORY          TAG                        IMAGE ID            CREATED             SIZE
thajeztah/myimage   latest                     b534869c81f0        41 hours ago        1.22MB
thajeztah/myimage   v1.0.0                     b534869c81f0        41 hours ago        1.22MB

Running the same command (docker push thajeztah/myimage) will push both images
to Docker Hub.

Note that the behavior described above is currently not (clearly) documented;
the docker push reference documentation (https://docs.docker.com/engine/reference/commandline/push/)
does not mention that omitting the tag will push all tags

This patch changes the default behavior, and if no tag is specified, :latest is
assumed. To push all tags, a new flag (-a / --all-tags) is added, similar
to the flag that's present on docker pull.

With this change:

  • docker push myname/myimage will be the equivalent of docker push myname/myimage:latest
  • to push all images, the user needs to set a flag (--all-tags), so docker push --all-tags myname/myimage:latest

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah force-pushed the push_all_flag branch 2 times, most recently from bed01ba to 3bc889c Compare December 9, 2019 14:46
thaJeztah added a commit to thaJeztah/cli that referenced this pull request Jan 7, 2020
full diff: moby/moby@a09e6e3...a9507c6

Includes:

- moby/moby#40077 Update "auto-generate" comments to improve detection by linters
- moby/moby#40143 registry: add a critical section to protect authTransport.modReq
- moby/moby#40212 Move DefaultCapabilities() to caps package
- moby/moby#40021 Use newer x/sys/windows SecurityAttributes struct (carry 40017)
    - carries moby/moby#40017 Use newer x/sys/windows SecurityAttributes struct
- moby/moby#40135 pkg/system: make OSVersion an alias for hcsshim OSVersion
    - follow-up to moby/moby#39100 Use Microsoft/hcsshim constants and deprecate pkg/system.GetOsVersion()
- moby/moby#40250 Bump hcsshim to b3f49c06ffaeef24d09c6c08ec8ec8425a0303e2
- moby/moby#40243 Use certs.d from XDG_CONFIG_HOME when in rootless mode
    - fixes moby/moby#40236 Docker rootless dies when unable to read /etc/docker/certs.d
- moby/moby#40283 Fix possible runtime panic in Lgetxattr
- moby/moby#40178 builder/remotecontext: small refactor
- moby/moby#40179 builder/remotecontext: allow ssh:// for remote context URLs
    - fixes docker#2164 Docker build cannot resolve git context with html escapes
- moby/moby#40302 client.ImagePush(): default to ":latest" instead of "all tags"
    - relates to docker#2214 [proposal] change "docker push" behavior to default to ":latest" instead of "all tags"
    - relates to docker#2220 implement docker push `-a`/ `--all-tags`
- moby/moby#40263 Normalize comment formatting
- moby/moby#40238 Allow client consumers like traefik to compile on illumos
- moby/moby#40108 bump google.golang.org/grpc v1.23.1
- moby/moby#40312 update vendor golang.org/x/sys to 6d18c012aee9febd81bbf9806760c8c4480e870d
- moby/moby#40247 pkg/system: deprecate constants in favor of golang.org/x/sys/windows
- moby/moby#40246 pkg/system: minor cleanups and remove use of deprecated system.GetOSVersion()
- moby/moby#40122 Update buildkit to containerd leases
    - vendor: update buildkit to leases support (4f4e03067523b2fc5ca2f17514a5e75ad63e02fb)
    - vendor: update containerd to acdcf13d5eaf0dfe0eaeabe7194a82535549bc2b
    - vendor: update runc to d736ef14f0288d6993a1845745d6756cfc9ddd5a (v1.0.0-rc9)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the push_all_flag branch 2 times, most recently from 102d21a to ece40a1 Compare January 9, 2020 15:05
docker-jenkins pushed a commit to docker-archive/docker-ce that referenced this pull request Jan 9, 2020
full diff: moby/moby@a09e6e3...a9507c6

Includes:

- moby/moby#40077 Update "auto-generate" comments to improve detection by linters
- moby/moby#40143 registry: add a critical section to protect authTransport.modReq
- moby/moby#40212 Move DefaultCapabilities() to caps package
- moby/moby#40021 Use newer x/sys/windows SecurityAttributes struct (carry 40017)
    - carries moby/moby#40017 Use newer x/sys/windows SecurityAttributes struct
- moby/moby#40135 pkg/system: make OSVersion an alias for hcsshim OSVersion
    - follow-up to moby/moby#39100 Use Microsoft/hcsshim constants and deprecate pkg/system.GetOsVersion()
- moby/moby#40250 Bump hcsshim to b3f49c06ffaeef24d09c6c08ec8ec8425a0303e2
- moby/moby#40243 Use certs.d from XDG_CONFIG_HOME when in rootless mode
    - fixes moby/moby#40236 Docker rootless dies when unable to read /etc/docker/certs.d
- moby/moby#40283 Fix possible runtime panic in Lgetxattr
- moby/moby#40178 builder/remotecontext: small refactor
- moby/moby#40179 builder/remotecontext: allow ssh:// for remote context URLs
    - fixes docker/cli#2164 Docker build cannot resolve git context with html escapes
- moby/moby#40302 client.ImagePush(): default to ":latest" instead of "all tags"
    - relates to docker/cli#2214 [proposal] change "docker push" behavior to default to ":latest" instead of "all tags"
    - relates to docker/cli#2220 implement docker push `-a`/ `--all-tags`
- moby/moby#40263 Normalize comment formatting
- moby/moby#40238 Allow client consumers like traefik to compile on illumos
- moby/moby#40108 bump google.golang.org/grpc v1.23.1
- moby/moby#40312 update vendor golang.org/x/sys to 6d18c012aee9febd81bbf9806760c8c4480e870d
- moby/moby#40247 pkg/system: deprecate constants in favor of golang.org/x/sys/windows
- moby/moby#40246 pkg/system: minor cleanups and remove use of deprecated system.GetOSVersion()
- moby/moby#40122 Update buildkit to containerd leases
    - vendor: update buildkit to leases support (4f4e03067523b2fc5ca2f17514a5e75ad63e02fb)
    - vendor: update containerd to acdcf13d5eaf0dfe0eaeabe7194a82535549bc2b
    - vendor: update runc to d736ef14f0288d6993a1845745d6756cfc9ddd5a (v1.0.0-rc9)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Upstream-commit: 627a4cf7ccd0b7e92c6798c73de4dd4efc43175c
Component: cli
@thaJeztah thaJeztah force-pushed the push_all_flag branch 5 times, most recently from c3842b6 to 6e9c99e Compare January 15, 2020 17:20
@thaJeztah thaJeztah force-pushed the push_all_flag branch 2 times, most recently from 5fb5e80 to e4b808b Compare January 16, 2020 11:37
@thaJeztah thaJeztah marked this pull request as ready for review January 16, 2020 11:50
@thaJeztah thaJeztah requested a review from albers as a code owner January 16, 2020 11:50
@thaJeztah thaJeztah changed the title [WIP] implement docker push -a/--all-tags implement docker push -a/--all-tags Jan 16, 2020
docs/reference/commandline/push.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@albers albers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah
Copy link
Member Author

e2e looks to be flaky/broken (don't think due to this PR). I was wondering why some PR's were green, but I noticed the Jenkins jobs were not triggered on all PR's. I opened #2256 and #2257 (but they probably are the same issue)

@thaJeztah
Copy link
Member Author

@silvin-lubecki PTAL - kicked CI, and it's green now 👍

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@silvin-lubecki silvin-lubecki merged commit 5d0cf88 into docker:master Jan 30, 2020
@thaJeztah thaJeztah deleted the push_all_flag branch January 30, 2020 15:27
@thaJeztah thaJeztah added this to the next milestone Feb 5, 2020
eiffel-fl pushed a commit to eiffel-fl/cli that referenced this pull request Jul 28, 2020
full diff: moby/moby@a09e6e3...a9507c6

Includes:

- moby/moby#40077 Update "auto-generate" comments to improve detection by linters
- moby/moby#40143 registry: add a critical section to protect authTransport.modReq
- moby/moby#40212 Move DefaultCapabilities() to caps package
- moby/moby#40021 Use newer x/sys/windows SecurityAttributes struct (carry 40017)
    - carries moby/moby#40017 Use newer x/sys/windows SecurityAttributes struct
- moby/moby#40135 pkg/system: make OSVersion an alias for hcsshim OSVersion
    - follow-up to moby/moby#39100 Use Microsoft/hcsshim constants and deprecate pkg/system.GetOsVersion()
- moby/moby#40250 Bump hcsshim to b3f49c06ffaeef24d09c6c08ec8ec8425a0303e2
- moby/moby#40243 Use certs.d from XDG_CONFIG_HOME when in rootless mode
    - fixes moby/moby#40236 Docker rootless dies when unable to read /etc/docker/certs.d
- moby/moby#40283 Fix possible runtime panic in Lgetxattr
- moby/moby#40178 builder/remotecontext: small refactor
- moby/moby#40179 builder/remotecontext: allow ssh:// for remote context URLs
    - fixes docker#2164 Docker build cannot resolve git context with html escapes
- moby/moby#40302 client.ImagePush(): default to ":latest" instead of "all tags"
    - relates to docker#2214 [proposal] change "docker push" behavior to default to ":latest" instead of "all tags"
    - relates to docker#2220 implement docker push `-a`/ `--all-tags`
- moby/moby#40263 Normalize comment formatting
- moby/moby#40238 Allow client consumers like traefik to compile on illumos
- moby/moby#40108 bump google.golang.org/grpc v1.23.1
- moby/moby#40312 update vendor golang.org/x/sys to 6d18c012aee9febd81bbf9806760c8c4480e870d
- moby/moby#40247 pkg/system: deprecate constants in favor of golang.org/x/sys/windows
- moby/moby#40246 pkg/system: minor cleanups and remove use of deprecated system.GetOSVersion()
- moby/moby#40122 Update buildkit to containerd leases
    - vendor: update buildkit to leases support (4f4e03067523b2fc5ca2f17514a5e75ad63e02fb)
    - vendor: update containerd to acdcf13d5eaf0dfe0eaeabe7194a82535549bc2b
    - vendor: update runc to d736ef14f0288d6993a1845745d6756cfc9ddd5a (v1.0.0-rc9)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
aslushnikov added a commit to aslushnikov/playwright that referenced this pull request Sep 2, 2020
We rely on `docker push --all-tags` flag that exists only in the
new version of docker.

The PR to docker with the flag: docker/cli#2220
aslushnikov added a commit to microsoft/playwright that referenced this pull request Sep 2, 2020
We rely on `docker push --all-tags` flag that exists only in the
new version of docker.

The PR to docker with the flag: docker/cli#2220
jlevesy added a commit to upfluence/ubuild that referenced this pull request Feb 11, 2021
Docker 20.04 introduced a breaking change  docker/cli#2220 that only pushes :latest when docker push is run without an explicit tag
jlevesy added a commit to upfluence/ubuild that referenced this pull request Feb 11, 2021
Docker 20.04 introduced a breaking change  docker/cli#2220 that only pushes :latest when docker push is run without an explicit tag.
To solve this issue, we now pass explicitely the list of tagis to push.
jlevesy added a commit to upfluence/ubuild that referenced this pull request Feb 11, 2021
Docker 20.04 introduced a breaking change  docker/cli#2220 that only pushes :latest when docker push is run without an explicit tag.
To solve this issue, we now pass the "-a" option, which pushes all images
jlevesy added a commit to upfluence/ubuild that referenced this pull request Feb 11, 2021
Docker 20.04 introduced a breaking change  docker/cli#2220 that only pushes :latest when docker push is run without an explicit tag.
To solve this issue, we now pass the "-a" option, which pushes all images
kimburgess added a commit to PlaceOS/PlaceOS that referenced this pull request Feb 15, 2021
Resolves an issue with image publishing due to new behaviour introduced by docker/cli#2220.
kimburgess added a commit to PlaceOS/PlaceOS that referenced this pull request Feb 15, 2021
Resolves an issue with image publishing due to new behaviour introduced by docker/cli#2220.
TheEadie added a commit to TheEadie/WormsLeague that referenced this pull request Mar 15, 2021
docker/cli#2220 broke the release script
xeronimus pushed a commit to Zuehlke/poinz that referenced this pull request Jun 15, 2021
…ere was a "recent" change regarding the default behavior

up until v0.9.1, docker pushed all tags by default. after that, the option "--all-tags" was introduced. default is now pushing only the "latest" image.

docker/cli#2220
mlabardini-opti added a commit to optimizely/agent that referenced this pull request Jan 14, 2022
Mat001 pushed a commit to optimizely/agent that referenced this pull request Jan 14, 2022
leeonlee added a commit to GoogleCloudPlatform/cloud-builders that referenced this pull request May 9, 2022
The Docker 20 client changes the default `docker push` behavior to only
push the `latest` tag when no tags are specificed. See
docker/cli#2220
leeonlee added a commit to GoogleCloudPlatform/cloud-builders that referenced this pull request May 9, 2022
The docker 20 client changes the default `docker push` behavior to push
the `latest` tag when no tags are specified. See
docker/cli#2220.
leeonlee added a commit to GoogleCloudPlatform/cloud-builders that referenced this pull request May 9, 2022
The docker 20 client changes the default `docker push` behavior to push
the `latest` tag when no tags are specified. See
docker/cli#2220.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[proposal] change "docker push" behavior to default to ":latest" instead of "all tags"
4 participants