{"record":{"id":"887f2283a64576f4","repo":"docker/cli","slug":"unable-to-setup-input-stream-s","errorCode":null,"errorMessage":"unable to setup input stream: %s","messagePattern":"unable to setup input stream: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/hijack.go","lineNumber":64,"sourceCode":"\tstreams      command.Streams\n\tinputStream  io.ReadCloser\n\toutputStream io.Writer\n\terrorStream  io.Writer\n\n\tresp client.HijackedResponse\n\n\ttty        bool\n\tdetachKeys string\n}\n\n// stream handles setting up the IO and then begins streaming stdin/stdout\n// to/from the hijacked connection, blocking until it is either done reading\n// output, the user inputs the detach key sequence when in TTY mode, or when\n// the given context is cancelled.\nfunc (h *hijackedIOStreamer) stream(ctx context.Context) error {\n\trestoreInput, err := h.setupInput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to setup input stream: %s\", err)\n\t}\n\n\tdefer restoreInput()\n\n\toutputDone := h.beginOutputStream(restoreInput)\n\tinputDone, detached := h.beginInputStream(restoreInput)\n\n\tselect {\n\tcase err := <-outputDone:\n\t\treturn err\n\tcase <-inputDone:\n\t\t// Input stream has closed.\n\t\tif h.outputStream != nil || h.errorStream != nil {\n\t\t\t// Wait for output to complete streaming.\n\t\t\tselect {\n\t\t\tcase err := <-outputDone:\n\t\t\t\treturn err\n\t\t\tcase <-ctx.Done():","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/hijack.go#L46-L82","documentation":"Returned by hijackedIOStreamer.stream (hijack.go:64) when h.setupInput() fails. setupInput performs detach-keys validation and raw-terminal setup, so this error wraps whichever of those failed. It surfaces during `docker attach`/`exec`/interactive `run` over a hijacked connection.","triggerScenarios":"An interactive container session where setupInput fails: invalid --detach-keys (most common), or a failure putting the input stream into raw mode for TTY handling.","commonSituations":"Bad --detach-keys value, a non-TTY stdin when a TTY was requested, or a terminal that cannot be set to raw mode.","solutions":["Fix the --detach-keys value (see error 286).","Ensure stdin is a real TTY: run from an interactive shell, not piped input, or drop -it.","Verify the terminal emulator supports raw mode."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check both inputs to setupInput: detach keys and TTY availability:\nif detachKeys != \"\" { if _, err := term.ToBytes(detachKeys); err != nil { return err } }\nif isTTY && !term.IsTerminal(os.Stdin.Fd()) { return errors.New(\"stdin is not a TTY\") }","typeGuard":null,"tryCatchPattern":"// setupInput failures are user/environment errors; surface a hint rather than retry.\nif err := streamer.stream(ctx); err != nil && strings.Contains(err.Error(), \"unable to setup input stream\") {\n    fmt.Fprintln(os.Stderr, \"check --detach-keys and TTY availability\")\n}","preventionTips":["Ensure a real TTY for interactive sessions.","Validate --detach-keys before attaching.","Avoid piping stdin when -t is set."],"tags":["container","terminal","streaming","hijack","cli"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}