Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cli/command/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
}
}
Expand Down Expand Up @@ -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: ")
Expand Down
6 changes: 3 additions & 3 deletions cli/command/registry/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
30 changes: 25 additions & 5 deletions docs/reference/commandline/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |


<!---MARKER_GEN_END-->
Expand Down Expand Up @@ -229,6 +229,26 @@ with the username `moby`. The password is entered interactively.
$ docker login -u moby
```

### <a name="access-token"></a> 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.

### <a name="password-stdin"></a> Provide a password using STDIN (--password-stdin)

To run the `docker login` command non-interactively, you can set the
Expand Down
Loading