Skip to content

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

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:use_all_tags_option
Dec 12, 2019
Merged

client.ImagePush(): default to ":latest" instead of "all tags"#40302
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:use_all_tags_option

Conversation

@thaJeztah
Copy link
Member

relates to docker/cli#2214 and docker/cli#2220

The docker push command up until docker 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,
and 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 issue #3411 and #4948 (commit e648a18).

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

docker pull had a similar behavior, but #7759 (9c08364)
changed the behavior to default to the :latest tag, and added a --all-tags flag
to the CLI to optionally pull all images.

This patch implements the API client changes to make docker push match the behavior
of docker pull, and default to pull a single image, unless the all option is passed.

- 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)

The `docker push` command up until docker 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`,
and `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 issue 3411 and PR 4948 (commit e648a18).

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

`docker pull` had a similar behavior, but PR 7759 (9c08364)
changed the behavior to default to the `:latest` tag, and added a `--all-tags` flag
to the CLI to optionally pull all images.

This patch implements the API client changes to make `docker push` match the behavior
of `docker pull`, and default to pull a single image, unless the `all` option is passed.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah marked this pull request as ready for review December 10, 2019 13:37

query := url.Values{}
query.Set("tag", tag)
if !options.All {
Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering if we should produce an error if options.All is set and image contains a tag; currently this situation is handled in the CLI;

	case opts.all && !reference.IsNameOnly(ref):
 		return errors.New("tag can't be used with --all-tags/-a")

Which is the same as how it's handled for docker pull, but perhaps we want that case to be handled by the client instead.

Also happy to do that in a follow-up and do it for both Push and Pull if we want them to act consistent.

@thaJeztah
Copy link
Member Author

ping @tianon @dmcgowan @tiborvass PTAL

Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

IMO this is fine as-is (given the edge case is not likely common); LGTM

@tonistiigi tonistiigi requested a review from dmcgowan December 12, 2019 19:21
Copy link
Member

@dmcgowan dmcgowan 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 thaJeztah merged commit a0bbe36 into moby:master Dec 12, 2019
@thaJeztah thaJeztah deleted the use_all_tags_option branch December 12, 2019 19:54
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]>
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 added this to the 20.03.0 milestone Apr 2, 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]>
KSmanis added a commit to KSmanis/gentoo-docker-images that referenced this pull request Feb 13, 2021
Up until now, the build was relying on an undocumented--but well
established--"feature" of the docker push command, namely the fact that
if no tag was specified, all built tags would be pushed. This was
recently changed [1], requiring the `--all-tags` flag to emulate the
previous behavior.

[1] moby/moby#40302
KSmanis added a commit to KSmanis/gentoo-docker-images that referenced this pull request Feb 13, 2021
Up until now, the build was relying on an undocumented--but well
established--"feature" of the docker push command, namely the fact that
if no tag was specified, all built tags would be pushed. This was
recently changed [1], requiring the `--all-tags` flag to emulate the
previous behavior.

[1] moby/moby#40302
KSmanis added a commit to KSmanis/gentoo-docker-images that referenced this pull request Feb 13, 2021
Up until now, the build was relying on an undocumented--but well
established--"feature" of the docker push command, namely the fact that
if no tag was specified, all built tags would be pushed. This was
recently changed [1], requiring the `--all-tags` flag to emulate the
previous behavior.

[1] moby/moby#40302

Signed-off-by: Konstantinos Smanis <[email protected]>
gentoo-bot pushed a commit to gentoo/gentoo-docker-images that referenced this pull request Feb 13, 2021
Up until now, the build was relying on an undocumented--but well
established--"feature" of the docker push command, namely the fact that
if no tag was specified, all built tags would be pushed. This was
recently changed [1], requiring the `--all-tags` flag to emulate the
previous behavior.

[1] moby/moby#40302

Signed-off-by: Konstantinos Smanis <[email protected]>
Signed-off-by: Alexys Jacob <[email protected]>
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.

4 participants