docker/cli · error
error: password is required
Error message
error: password is required
What it means
Raised by PromptUserForCredentials (cli/command/registry.go:180) when the interactive Password prompt (with terminal echo disabled) returns an empty string. Unlike the username, there is no stored default for the password, so an empty entry immediately fails the login.
Source
Thrown at cli/command/registry.go:180
// e.g., 'run stty echo' when in a Linux or macOS shell, but
// PowerShell and CMD.exe may need different instructions.
_, _ = fmt.Fprintln(cli.Err(), "Error: failed to restore terminal state to echo input:", err)
}
}()
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")
}
argPassword, err = prompt.ReadInput(ctx, stdIn, cli.Out(), "Password: ")
if err != nil {
return registrytypes.AuthConfig{}, err
}
_, _ = fmt.Fprintln(cli.Out())
if argPassword == "" {
return registrytypes.AuthConfig{}, errors.New("error: password is required")
}
}
return registrytypes.AuthConfig{
Username: argUser,
Password: argPassword,
ServerAddress: serverAddress,
}, nil
}
// RetrieveAuthTokenFromImage retrieves an encoded auth token given a
// complete image reference. The auth configuration is serialized as a
// base64url encoded ([RFC 4648, Section 5]) JSON string for sending through
// the "X-Registry-Auth" header.
//
// [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
func RetrieveAuthTokenFromImage(cfg *configfile.ConfigFile, image string) (string, error) {
registryRef, err := reference.ParseNormalizedNamed(image)View on GitHub (pinned to e9452d6e78)
Solutions
- Enter the password or Personal Access Token at the prompt (input is hidden — it is being read even though nothing is displayed)
- For non-interactive use, pipe the secret: echo "$PASSWORD" | docker login -u <user> --password-stdin
- For Docker Hub, generate a PAT at https://app.docker.com/settings and use it in place of the account password
Example fix
# before docker login # Password: <enter> # error: password is required # after printf '%s' "$DOCKER_PAT" | docker login -u myuser --password-stdin
When it happens
Trigger: Running `docker login` without -p/--password-stdin and pressing Enter at the Password prompt; piping input that supplies a username line but no password line, causing ReadInput to return empty.
Common situations: Users pasting a token that fails to paste into a no-echo terminal (some terminals block paste when echo is off); scripts feeding credentials via a heredoc that is missing the password line; confusion between password auth and token auth where the user expects a browser/device flow instead of a prompt.
Related errors
- error: username is required
- conflicting options: cannot specify both --password and --pa
- the --password-stdin option requires --username to be set
- username is empty
- password is empty
AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01).
Data as JSON: /data/errors/411acabda4d840d8.json.
Report an issue: GitHub.