Skip to content

Conversation

@Benehiko
Copy link
Member

@Benehiko Benehiko commented Jul 11, 2025

Relates to:

- What I did

This patch removes the interactive prompts from docker push/pull.
The prompt would only execute on a response status code 403 from the registry
after trying the value set in RegistryAuth. Docker Hub could return 404
instead or 429, which would never execute the prompt.

The UX regarding the prompt is also questionable since the user might
not actually want to authenticate with a registry and the CLI could fail fast
instead. The user can always run docker login or set the DOCKER_AUTH_CONFIG
environment variable to get authenticated.

- How I did it

- How to verify it

- Human readable description for the release notes

Remove interactive login prompt from `docker push` and `docker pull`. Previously, a `docker pull` could trigger an interactive login prompt if the pull failed because authentication was needed, which could disrupt non-interactive use.
This behavior depended on the registry from which the image was pulled (or pushed to), and the authentication mechanism used, making this behavior unpredictable. Instead, the cli now prints the error message produced by the registry, exiting with a non-zero exit code.

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Deprecate RegistryAuthenticationPrivilegedFunc and remove its usage from various CLI commands, replacing interactive fallback prompts with a nil default.

  • Mark RegistryAuthenticationPrivilegedFunc as deprecated.
  • Remove requestPrivilege logic and set PrivilegeFunc to nil in commands: sign, search, plugin install, image pull, and image push.
  • Ensure no interactive credential prompt fallback is invoked by default.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
cli/command/trust/sign.go Remove requestPrivilege logic and set PrivilegeFunc to nil
cli/command/registry/search.go Remove requestPrivilege logic and set PrivilegeFunc to nil
cli/command/registry.go Add deprecation comment to RegistryAuthenticationPrivilegedFunc
cli/command/plugin/install.go Remove requestPrivilege logic and set PrivilegeFunc to nil
cli/command/image/trust.go Remove requestPrivilege logic and set PrivilegeFunc to nil
cli/command/image/push.go Remove requestPrivilege logic and set PrivilegeFunc to nil

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/plugin/upgrade.go 0.00% 1 Missing ⚠️
cli/command/registry/search.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Benehiko Benehiko requested a review from thaJeztah July 11, 2025 12:27
@Benehiko Benehiko force-pushed the remove-prompt-privilege-func branch 2 times, most recently from 99e60c5 to ae3e756 Compare July 11, 2025 15:02
@Benehiko Benehiko marked this pull request as ready for review July 11, 2025 15:04
//
// Deprecated: this function is no longer used and will be removed in the next release.
func RegistryAuthenticationPrivilegedFunc(cli Cli, index *registrytypes.IndexInfo, cmdName string) registrytypes.RequestAuthConfig {
Copy link
Member

Choose a reason for hiding this comment

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

I should probably dust-off #5925, where I was playing with some options to get some of the nasty "IndexInfo" uses out. In that branch I added a NewAuthRequester function, that's probably more convenient to use for most;

But I was still contemplating if it should also accept a reference.Named as alternative to a string (for the image ref);

// and the given cmdName (used as informational message to the user).
//
// The returned function is a [registrytypes.RequestAuthConfig] to prompt the user
// for credentials if needed. It is called as fallback if the credentials (if any)
// used for the initial operation did not work.
//
// TODO(thaJeztah): cli Cli could be a Streams if it was not for cli.SetIn to be needed?
// TODO(thaJeztah): ideally, this would accept reposName / imageRef as a regular string (we can parse it if needed!), or .. maybe generics and accept either?
func NewAuthRequester(cli Cli, indexServer string, promptMsg string) registrytypes.RequestAuthConfig {

Comment on lines -118 to -121
var requestPrivilege registrytypes.RequestAuthConfig
if dockerCli.In().IsTerminal() {
requestPrivilege = command.RegistryAuthenticationPrivilegedFunc(dockerCli, repoInfo.Index, "push")
}
Copy link
Member

Choose a reason for hiding this comment

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

If you have time; perhaps cleaner would be to;

  • Put these changes in a separate commit / PR (change-log would be about docker push / docker pull no longer triggers an interactive login prompt)
  • The "deprecation" in a separate commit/PR (change-log would be relevant for users of the go module, not impacting end-users)

Separate commits, but same PR is probably fine, but would be good to update the PR title (and change-log to have separate items for each, because different audience).

Copy link
Member Author

Choose a reason for hiding this comment

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

follow-up PR to deprecate #6184

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

change itself LGTM, but left a comment about splitting the change in behavior from the deprecation.

This patch removes the interactive prompts from `docker push/pull`.
The prompt would only execute on a response status code 403 from the registry
after trying the value set in `RegistryAuth`. Docker Hub could return 404
instead or 429, which would never execute the prompt.

The UX regarding the prompt is also questionable since the user might
not actually want to authenticate with a registry and the CLI could fail fast
instead. The user can always run `docker login` or set the `DOCKER_AUTH_CONFIG`
environment variable to get authenticated.

Signed-off-by: Alano Terblanche <[email protected]>
@Benehiko Benehiko force-pushed the remove-prompt-privilege-func branch from ae3e756 to 7c8c267 Compare July 16, 2025 07:03
@Benehiko Benehiko force-pushed the remove-prompt-privilege-func branch from 7c8c267 to 2b56b66 Compare July 16, 2025 07:05
@Benehiko Benehiko changed the title cli/command: Deprecate RegistryAuthenticationPrivilegedFunc cli/command: remove interactive login prompt from docker push/pull Jul 16, 2025
@Benehiko Benehiko requested a review from thaJeztah July 16, 2025 07:11
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

I expanded the change-log description a bit; let me know if that looks good to you (also hinted at "returning the error from the registry, as I'm in process of surfacing the actual error from the registry, instead of hiding it behind our generic message).

@Benehiko
Copy link
Member Author

The changelog looks good, we can merge

@thaJeztah thaJeztah merged commit 6bcc9ce into docker:master Jul 16, 2025
105 checks passed
@thaJeztah thaJeztah added this to the 29.0.0 milestone Aug 13, 2025
@vvoland vvoland added the kind/bugfix PR's that fix bugs label Aug 14, 2025
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