{"record":{"id":"614fc777bfedbfbc","repo":"docker/cli","slug":"requested-load-from-stdin-but-stdin-is-empty","errorCode":null,"errorMessage":"requested load from stdin, but stdin is empty","messagePattern":"requested load from stdin, but stdin is empty","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/image/load.go","lineNumber":64,"sourceCode":"\tflags.StringVarP(&opts.input, \"input\", \"i\", \"\", \"Read from tar archive file, instead of STDIN\")\n\tflags.BoolVarP(&opts.quiet, \"quiet\", \"q\", false, \"Suppress the load output\")\n\tflags.StringSliceVar(&opts.platform, \"platform\", []string{}, `Load only the given platform(s). Formatted as a comma-separated list of \"os[/arch[/variant]]\" (e.g., \"linux/amd64,linux/arm64/v8\").`)\n\t_ = flags.SetAnnotation(\"platform\", \"version\", []string{\"1.48\"})\n\n\t_ = cmd.RegisterFlagCompletionFunc(\"platform\", completion.Platforms())\n\treturn cmd\n}\n\nfunc runLoad(ctx context.Context, dockerCli command.Cli, opts loadOptions) error {\n\tvar input io.Reader = dockerCli.In()\n\n\t// TODO(thaJeztah): add support for \"-\" as STDIN to match other commands, possibly making it a required positional argument.\n\tswitch opts.input {\n\tcase \"\":\n\t\t// To avoid getting stuck, verify that a tar file is given either in\n\t\t// the input flag or through stdin and if not display an error message and exit.\n\t\tif dockerCli.In().IsTerminal() {\n\t\t\treturn errors.New(\"requested load from stdin, but stdin is empty\")\n\t\t}\n\tdefault:\n\t\t// We use sequential.Open to use sequential file access on Windows, avoiding\n\t\t// depleting the standby list un-necessarily. On Linux, this equates to a regular os.Open.\n\t\tfile, err := sequential.Open(opts.input)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer func() { _ = file.Close() }()\n\t\tinput = file\n\t}\n\n\tvar options []client.ImageLoadOption\n\tif opts.quiet || !dockerCli.Out().IsTerminal() {\n\t\toptions = append(options, client.ImageLoadWithQuiet(true))\n\t}\n\n\tplatformList := []ocispec.Platform{}","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/image/load.go#L46-L82","documentation":"runLoad() defaults input to stdin. To avoid blocking forever waiting for data that will never arrive, it checks dockerCli.In().IsTerminal(): if no -i file was given and stdin is an interactive TTY (nothing piped), it errors immediately instead of hanging.","triggerScenarios":"Running `docker load` interactively in a shell with no -i flag and no input redirection.","commonSituations":"Forgetting to redirect a previously saved tar; running the command manually expecting a file picker.","solutions":["Pass an input file: `docker load -i image.tar`","Redirect from a file: `docker load < image.tar`","Pipe from a producer command so stdin is not a TTY"],"exampleFix":"// before\ndocker load\n// after\ndocker load -i image.tar\n// or\ndocker load < image.tar","handlingStrategy":"validation","validationCode":"if opts.input == \"\" && dockerCli.In().IsTerminal() {\n    return errors.New(\"no input: pass -i <file> or pipe a tar archive on stdin\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use -i <file> in scripts and CI for `docker load`","Redirect or pipe input rather than relying on an interactive stdin","Guard wrapper scripts with `[ -t 0 ]` to detect a missing pipe before load"],"tags":["images","cli","stdin-stdout"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}