Skip to content
Merged
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
12 changes: 5 additions & 7 deletions cli/command/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ 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."
patOrOatSuggest = "You can log in with your password, a Personal Access " +
"Token (PAT), or an Organization Access Token (OAT). Using a limited-scope PAT " +
"or OAT grants better security, and a PAT is required for organizations using SSO. " +
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/"
)

Expand Down Expand Up @@ -168,10 +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) or Organization Access Token (OAT) can be used instead.\n" +
"To create a PAT, visit " + aec.Underline.Apply("https://app.docker.com/settings") + "\n" +
"To create an OAT, visit " + aec.Underline.Apply("https://app.docker.com") + " and select your organization, then Identity & auth > Access tokens.\n" +
"When using an OAT, use your organization name as the username.\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, or organization name when using an Organization Access Token (OAT)")
flags.StringVarP(&opts.password, "password", "p", "", `Password, Personal Access Token (PAT), or Organization Access Token (OAT), or "-" to read from stdin`)
flags.BoolVar(&opts.passwordStdin, "password-stdin", false, "Take the Password, Personal Access Token (PAT), or Organization Access Token (OAT) 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
34 changes: 16 additions & 18 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, Personal Access Token (PAT), or Organization Access Token (OAT), or `-` to read from stdin |
| [`--password-stdin`](#password-stdin) | `bool` | | Take the Password, Personal Access Token (PAT), or Organization Access Token (OAT) from stdin |
| [`-u`](#username), [`--username`](#username) | `string` | | Username, or organization name when using an Organization Access Token (OAT) |
| 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,27 +229,25 @@ with the username `moby`. The password is entered interactively.
$ docker login -u moby
```

### <a name="oat"></a> Authenticate with an organization access token (OAT)
### <a name="access-token"></a> Authenticate with an access token

To authenticate to Docker Hub with an [organization access token
(OAT)](https://docs.docker.com/security/access-tokens/organization-access-tokens/),
use your organization name as the username, and the OAT in place of a
password. The following example authenticates with the organization `myorg`.
The OAT is entered interactively at the password prompt.
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 run the command non-interactively, provide the OAT through `STDIN`:

```console
$ cat ~/my_oat.txt | docker login --username myorg --password-stdin
```
To authenticate non-interactively, see [Provide a password using STDIN](#password-stdin).

> [!NOTE]
> OATs don't work with Docker Desktop sign-in or Image Access Management. Use a
> personal access token (PAT) for those.
> 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)

Expand Down