{"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":"validation","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/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/registry/login.go#L220-L256","documentation":"Raised by loginUser (cli/command/registry/login.go:238) when the login needs to prompt interactively (username or password missing) but stdin is not a terminal (dockerCLI.In().IsTerminal() is false). Prompting for hidden-input credentials requires a real character device; a pipe or redirected stdin cannot support the no-echo password prompt, so the CLI fails up front. The source comments note this hits `cat | docker login` on Linux and mintty on Windows, where stdin is a pipe rather than a console.","triggerScenarios":"Running docker login with incomplete credentials (missing -u or password) in any non-TTY context: piped stdin (cat creds | docker login without --password-stdin), CI jobs, cron, docker exec without -t, ssh without -t, Git Bash/mintty/MSYS on Windows where stdin is emulated as a pipe.","commonSituations":"CI pipelines calling bare `docker login` expecting prompts; Windows users on mintty/Git Bash hitting this even in an apparently interactive shell (fix: prefix with winpty or use Windows Terminal); scripts that pipe the password on stdin but forget --password-stdin, so the CLI still thinks it must prompt.","solutions":["Supply full credentials non-interactively: printf '%s' \"$TOKEN\" | docker login -u \"$USER\" --password-stdin <registry>","On mintty/Git Bash, run `winpty docker login` or use a console with real TTY semantics (Windows Terminal, PowerShell, CMD)","When running through ssh or docker exec, allocate a TTY (ssh -t, docker exec -it) if interactive login is genuinely wanted"],"exampleFix":"# before (CI, no TTY)\ndocker login registry.example.com\n\n# after\nprintf '%s' \"$REGISTRY_TOKEN\" | docker login -u \"$REGISTRY_USER\" --password-stdin registry.example.com","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","registry","authentication","tty","ci","windows"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}