{"record":{"id":"411acabda4d840d8","repo":"docker/cli","slug":"error-password-is-required","errorCode":null,"errorMessage":"error: password is required","messagePattern":"error: password is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/registry.go","lineNumber":180,"sourceCode":"\t\t\t\t//  e.g., 'run stty echo' when in a Linux or macOS shell, but\n\t\t\t\t//  PowerShell and CMD.exe may need different instructions.\n\t\t\t\t_, _ = fmt.Fprintln(cli.Err(), \"Error: failed to restore terminal state to echo input:\", err)\n\t\t\t}\n\t\t}()\n\n\t\tif serverAddress == authConfigKey {\n\t\t\tout := tui.NewOutput(cli.Err())\n\t\t\tout.PrintNote(\"A Personal Access Token (PAT) can be used instead.\\n\" +\n\t\t\t\t\"To create a PAT, visit \" + aec.Underline.Apply(\"https://app.docker.com/settings\") + \"\\n\\n\")\n\t\t}\n\n\t\targPassword, err = prompt.ReadInput(ctx, stdIn, cli.Out(), \"Password: \")\n\t\tif err != nil {\n\t\t\treturn registrytypes.AuthConfig{}, err\n\t\t}\n\t\t_, _ = fmt.Fprintln(cli.Out())\n\t\tif argPassword == \"\" {\n\t\t\treturn registrytypes.AuthConfig{}, errors.New(\"error: password is required\")\n\t\t}\n\t}\n\n\treturn registrytypes.AuthConfig{\n\t\tUsername:      argUser,\n\t\tPassword:      argPassword,\n\t\tServerAddress: serverAddress,\n\t}, nil\n}\n\n// RetrieveAuthTokenFromImage retrieves an encoded auth token given a\n// complete image reference. The auth configuration is serialized as a\n// base64url encoded ([RFC 4648, Section 5]) JSON string for sending through\n// the \"X-Registry-Auth\" header.\n//\n// [RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5\nfunc RetrieveAuthTokenFromImage(cfg *configfile.ConfigFile, image string) (string, error) {\n\tregistryRef, err := reference.ParseNormalizedNamed(image)","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/registry.go#L162-L198","documentation":"Thrown by PromptUserForCredentials after the interactive password prompt (with echo disabled) returns an empty string. The login flow requires a non-empty password or token.","triggerScenarios":"Interactive 'docker login' where the user presses Enter at the 'Password:' prompt without typing anything (registry.go lines 174-180).","commonSituations":"Accidental Enter; clipboard paste failure; using a PAT but pasting nothing.","solutions":["Type your password or PAT at the prompt.","Use --password-stdin to pipe the credential from a file or env var.","Generate a PAT at https://app.docker.com/settings if unsure of the password."],"exampleFix":"# before (pressing Enter at Password: prompt)\ndocker login -u myuser\n# after\nprintf '%s' \"$DOCKER_TOKEN\" | docker login -u myuser --password-stdin","handlingStrategy":"validation","validationCode":"// Ensure a password/token is available before the prompt\nif strings.TrimSpace(password) == \"\" {\n    return fmt.Errorf(\"a password or PAT is required; use --password-stdin\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use --password-stdin to supply a PAT from a secret store.","Generate a PAT and confirm it is non-empty before login.","Avoid interactive password entry in CI."],"tags":["registry","login","auth","docker","go","cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}