From ac057b79e5723c35220d92fe277f7551c94864b2 Mon Sep 17 00:00:00 2001 From: Maria Ines Parnisari Date: Fri, 20 Nov 2026 09:35:33 -0700 Subject: [PATCH] chore: update login to mention OATs Signed-off-by: Maria Ines Parnisari --- cli/command/registry.go | 13 +++++++------ cli/command/registry/login.go | 6 +++--- docs/reference/commandline/login.md | 30 ++++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/cli/command/registry.go b/cli/command/registry.go index 2e767d5b72f3..a949f8afed91 100644 --- a/cli/command/registry.go +++ b/cli/command/registry.go @@ -24,9 +24,10 @@ import ( const ( registerSuggest = "Log in with your Docker ID or email address to push and pull images from Docker Hub. " + "If you don't have a Docker ID, head over to https://hub.docker.com/ to create one." - patSuggest = "You can log in with your password or a Personal Access " + - "Token (PAT). Using a limited-scope PAT grants better security and is required " + - "for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/" + patOrOatSuggest = "You can use a personal access token (PAT) or organization access token (OAT) instead of a password. " + + "Scoped tokens improve security; a PAT is required for password-based login with SSO. " + + "When using an OAT, use your organization name as the username. " + + "Learn more at https://docs.docker.com/go/access-tokens/" ) // authConfigKey is the key used to store credentials for Docker Hub. It is @@ -123,7 +124,7 @@ func PromptUserForCredentials(ctx context.Context, cli Streams, argUser, argPass // a token instead of a password. _, _ = fmt.Fprintln(cli.Out(), registerSuggest) if hints.Enabled() { - _, _ = fmt.Fprintln(cli.Out(), patSuggest) + _, _ = fmt.Fprintln(cli.Out(), patOrOatSuggest) _, _ = fmt.Fprintln(cli.Out()) } } @@ -167,8 +168,8 @@ func PromptUserForCredentials(ctx context.Context, cli Streams, argUser, argPass if serverAddress == authConfigKey { out := tui.NewOutput(cli.Err()) - out.PrintNote("A Personal Access Token (PAT) can be used instead.\n" + - "To create a PAT, visit " + aec.Underline.Apply("https://app.docker.com/settings") + "\n\n") + out.PrintNote("You can use a personal access token (PAT) or organization access token (OAT) instead of a password.\n" + + "Learn more at " + aec.Underline.Apply("https://docs.docker.com/go/access-tokens/") + "\n\n") } argPassword, err = prompt.ReadInput(ctx, stdIn, cli.Out(), "Password: ") diff --git a/cli/command/registry/login.go b/cli/command/registry/login.go index 2b522910d800..ac2481835a31 100644 --- a/cli/command/registry/login.go +++ b/cli/command/registry/login.go @@ -62,9 +62,9 @@ func newLoginCommand(dockerCLI command.Cli) *cobra.Command { flags := cmd.Flags() - flags.StringVarP(&opts.user, "username", "u", "", "Username") - flags.StringVarP(&opts.password, "password", "p", "", `Password or Personal Access Token (PAT), or "-" to read from stdin`) - flags.BoolVar(&opts.passwordStdin, "password-stdin", false, "Take the Password or Personal Access Token (PAT) from stdin") + flags.StringVarP(&opts.user, "username", "u", "", "Username or organization name (for OATs)") + flags.StringVarP(&opts.password, "password", "p", "", `Password or access token. Use "-" to read from stdin`) + flags.BoolVar(&opts.passwordStdin, "password-stdin", false, "Read password or access token from stdin") return cmd } diff --git a/docs/reference/commandline/login.md b/docs/reference/commandline/login.md index 458edd7b91b0..4603bb96d655 100644 --- a/docs/reference/commandline/login.md +++ b/docs/reference/commandline/login.md @@ -6,11 +6,11 @@ Defaults to Docker Hub if no server is specified. ### Options -| Name | Type | Default | Description | -|:---------------------------------------------|:---------|:--------|:-------------------------------------------------------------------| -| `-p`, `--password` | `string` | | Password or Personal Access Token (PAT), or `-` to read from stdin | -| [`--password-stdin`](#password-stdin) | `bool` | | Take the Password or Personal Access Token (PAT) from stdin | -| [`-u`](#username), [`--username`](#username) | `string` | | Username | +| Name | Type | Default | Description | +|:---------------------------------------------|:---------|:--------|:-----------------------------------------------------| +| `-p`, `--password` | `string` | | Password or access token. Use `-` to read from stdin | +| [`--password-stdin`](#password-stdin) | `bool` | | Read password or access token from stdin | +| [`-u`](#username), [`--username`](#username) | `string` | | Username or organization name (for OATs) | @@ -229,6 +229,26 @@ with the username `moby`. The password is entered interactively. $ docker login -u moby ``` +### Authenticate with an access token + +To authenticate to Docker Hub with a [personal access token (PAT)](https://docs.docker.com/security/access-tokens/personal-access-tokens/) +or [organization access token (OAT)](https://docs.docker.com/security/access-tokens/organization-access-tokens/), +use the token in place of a password. + +For a PAT, use your Docker ID as the username. For an OAT, use your +organization name instead. The following example authenticates using +the organization `myorg`. The token is entered interactively. + +```console +$ docker login --username myorg +``` + +To authenticate non-interactively, see [Provide a password using STDIN](#password-stdin). + +> [!NOTE] +> OATs don't support Docker Desktop sign-in or Image Access Management. +> Use web-based sign-in or a PAT instead, where supported. + ### Provide a password using STDIN (--password-stdin) To run the `docker login` command non-interactively, you can set the