{"record":{"id":"e1467774b72a1ab7","repo":"docker/cli","slug":"error-cannot-perform-an-interactive-login-from-a","errorCode":null,"errorMessage":"error: cannot perform an interactive login from a non-TTY device","messagePattern":"error: cannot perform an interactive login from a non-TTY device","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/registry/login.go","lineNumber":238,"sourceCode":"\t}\n\n\tif err := storeCredentials(dockerCLI.ConfigFile(), authConfig); err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn resp.Auth.Status, err\n}\n\nfunc loginUser(ctx context.Context, dockerCLI command.Cli, opts loginOptions, defaultUsername, serverAddress string) (msg string, _ error) {\n\t// Some links documenting this:\n\t// - https://code.google.com/archive/p/mintty/issues/56\n\t// - https://github.com/docker/docker/issues/15272\n\t// - https://mintty.github.io/ (compatibility)\n\t// Linux will hit this if you attempt `cat | docker login`, and Windows\n\t// will hit this if you attempt docker login from mintty where stdin\n\t// is a pipe, not a character based console.\n\tif (opts.user == \"\" || opts.password == \"\") && !dockerCLI.In().IsTerminal() {\n\t\treturn \"\", errors.New(\"error: cannot perform an interactive login from a non-TTY device\")\n\t}\n\n\t// If we're logging into the index server and the user didn't provide a username or password, use the device flow\n\tif serverAddress == registry.IndexServer && opts.user == \"\" && opts.password == \"\" {\n\t\tvar err error\n\t\tmsg, err = loginWithDeviceCodeFlow(ctx, dockerCLI)\n\t\t// if the error represents a failure to initiate the device-code flow,\n\t\t// then we fallback to regular cli credentials login\n\t\tif !errors.Is(err, manager.ErrDeviceLoginStartFail) {\n\t\t\treturn msg, err\n\t\t}\n\t\t_, _ = fmt.Fprint(dockerCLI.Err(), \"Failed to start web-based login - falling back to command line login...\\n\\n\")\n\t}\n\n\treturn loginWithUsernameAndPassword(ctx, dockerCLI, opts, defaultUsername, serverAddress)\n}\n\nfunc loginWithUsernameAndPassword(ctx context.Context, dockerCLI command.Cli, opts loginOptions, defaultUsername, serverAddress string) (msg string, _ error) {","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/registry/login.go#L220-L256","documentation":"Thrown by loginUser when either the username or password is missing AND stdin is not a TTY. Without an interactive terminal the CLI cannot prompt for the missing credential, so it refuses rather than hang. This is the classic non-interactive/CI login failure.","triggerScenarios":"Running 'echo token | docker login' (no -u/-p) in a script or CI; 'cat file | docker login'; running under mintty/Git Bash where stdin is a pipe not a console (login.go lines 237-238).","commonSituations":"CI pipelines, cron jobs, non-interactive SSH sessions, Windows mintty/Git Bash pipes, any redirected stdin.","solutions":["Provide both credentials non-interactively: 'printf %s \"$TOKEN\" | docker login -u <user> --password-stdin'.","Run the command in a real interactive TTY if you want prompting.","Use a credential helper or stored credentials to avoid passing secrets at all."],"exampleFix":"# before (in CI)\necho \"$TOKEN\" | docker login\n# after\nprintf '%s' \"$TOKEN\" | docker login -u \"$DOCKER_USER\" --password-stdin","handlingStrategy":"validation","validationCode":"// Detect non-TTY stdin and require explicit credentials\nif (user == \"\" || password == \"\") && !in.IsTerminal() {\n    return fmt.Errorf(\"non-interactive login requires -u and --password-stdin\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In CI always pass -u and --password-stdin together.","Detect TTY availability in wrappers and fail with a clear message.","Use credential helpers to avoid passing secrets on the command line."],"tags":["registry","login","auth","tty","ci","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"}