Skip to content
Open
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
15 changes: 9 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 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. " +
"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,10 @@ 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("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")
}

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

return cmd
}
Expand Down
32 changes: 27 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, 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) |


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

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

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.

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

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

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