{"id":"bf5a4dc0865f9097","repo":"docker/cli","slug":"conflicting-options-cannot-specify-both-passwor","errorCode":null,"errorMessage":"conflicting options: cannot specify both --password and --password-stdin","messagePattern":"conflicting options: cannot specify both --password and --password-stdin","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/registry/login.go","lineNumber":77,"sourceCode":"\t\tDisableFlagsInUseLine: true,\n\t}\n\n\tflags := cmd.Flags()\n\n\tflags.StringVarP(&opts.user, \"username\", \"u\", \"\", \"Username\")\n\tflags.StringVarP(&opts.password, \"password\", \"p\", \"\", `Password or Personal Access Token (PAT), or \"-\" to read from stdin`)\n\tflags.BoolVar(&opts.passwordStdin, \"password-stdin\", false, \"Take the Password or Personal Access Token (PAT) from stdin\")\n\n\treturn cmd\n}\n\n// verifyLoginFlags validates flags set on the command.\n//\n// TODO(thaJeztah); combine with verifyLoginOptions, but this requires rewrites of many tests.\nfunc verifyLoginFlags(flags *pflag.FlagSet, opts loginOptions) error {\n\tif flags.Changed(\"password-stdin\") || opts.password == \"-\" {\n\t\tif flags.Changed(\"password\") && opts.password != \"-\" {\n\t\t\treturn errors.New(\"conflicting options: cannot specify both --password and --password-stdin\")\n\t\t}\n\t\tif !flags.Changed(\"username\") {\n\t\t\treturn errors.New(\"the --password-stdin option requires --username to be set\")\n\t\t}\n\t}\n\tif flags.Changed(\"username\") && opts.user == \"\" {\n\t\treturn errors.New(\"username is empty\")\n\t}\n\tif flags.Changed(\"password\") && opts.password == \"\" {\n\t\treturn errors.New(\"password is empty\")\n\t}\n\treturn nil\n}\n\n// readSecretFromStdin reads the secret from r and returns it as a string.\n// It trims terminal line-endings (LF, CRLF, or CR), which may be added when\n// inputting interactively or piping input. The value is otherwise treated as\n// opaque, preserving any other whitespace, including newlines, per [NIST SP 800-63B §5.1.1.2].","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/registry/login.go#L59-L95","documentation":"Raised by verifyLoginFlags (cli/command/registry/login.go:77) during flag validation of `docker login`. The command received both an explicit --password value and a request to read the password from stdin (--password-stdin, or the shorthand --password -). These are mutually exclusive sources for the same secret, so the CLI refuses to guess which one wins.","triggerScenarios":"docker login -u user --password secret --password-stdin; docker login -u user -p secret --password-stdin < token.txt. Note that `-p -` alone is treated as --password-stdin and does NOT trigger this error — only a non-'-' password combined with --password-stdin does.","commonSituations":"CI pipelines where a shared login step appends --password-stdin while a job also injects -p from a template; migrating scripts from the insecure -p pattern to --password-stdin and forgetting to remove the old flag; wrapper scripts that unconditionally add both flags.","solutions":["Remove the --password/-p flag and keep --password-stdin: echo \"$PASSWORD\" | docker login -u user --password-stdin","If stdin is not available in your environment, drop --password-stdin and use -p (accepting the insecure-CLI warning)","Audit CI templates/wrappers so exactly one password source is configured"],"exampleFix":"# before\necho \"$PW\" | docker login -u user -p \"$PW\" --password-stdin registry.example.com\n\n# after\necho \"$PW\" | docker login -u user --password-stdin registry.example.com","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","registry","authentication","flag-validation","ci"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}