Skip to content

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

Merged
silvin-lubecki merged 1 commit into
docker:masterfrom
thaJeztah:push_all_flag
Jan 30, 2020
Merged

implement docker push -a/--all-tags#2220
silvin-lubecki merged 1 commit into
docker:masterfrom
thaJeztah:push_all_flag

Conversation

@thaJeztah

@thaJeztahthaJeztah commented Dec 9, 2019

Copy link
Copy Markdown
Member

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
thaJeztahforce-pushed the push_all_flag branch 2 times, most recently from bed01ba to 3bc889cCompareDecember 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
- fixesmoby/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
- fixesdocker#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 <github@gone.nl>
@thaJeztah
thaJeztahforce-pushed the push_all_flag branch 2 times, most recently from 102d21a to ece40a1CompareJanuary 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
- fixesmoby/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
- fixesdocker/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 <github@gone.nl>
Upstream-commit: 627a4cf7ccd0b7e92c6798c73de4dd4efc43175c
Component: cli
@thaJeztah
thaJeztahforce-pushed the push_all_flag branch 5 times, most recently from c3842b6 to 6e9c99eCompareJanuary 15, 2020 17:20
@thaJeztah
thaJeztahforce-pushed the push_all_flag branch 2 times, most recently from 5fb5e80 to e4b808bCompareJanuary 16, 2020 11:37
@thaJeztah
thaJeztah marked this pull request as ready for review January 16, 2020 11:50
@thaJeztahthaJeztah changed the title [WIP] implement docker push -a/--all-tagsimplement docker push -a/--all-tagsJan 16, 2020
Comment threaddocs/reference/commandline/push.md Outdated

@albersalbers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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

Comment threadcli/command/image/push.go
Comment threadcli/command/image/push.go
The `docker push` command up until [v0.9.1](https://github.com/moby/moby/blob/v0.9.1/api/client.go#L998)
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`
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

@silvin-lubeckisilvin-lubecki left a comment

Copy link
Copy Markdown
Contributor

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:masterJan 30, 2020
@thaJeztah
thaJeztah deleted the push_all_flag branch January 30, 2020 15:27
@thaJeztahthaJeztah 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
- fixesmoby/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
- fixesdocker#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 <github@gone.nl>
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.
Sign up for freeto 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

@thaJeztah@albers@silvin-lubecki@GordonTheTurtle