{"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":"validation","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/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/image/load.go#L46-L82","documentation":"docker image load reads a tar archive from stdin when no --input/-i flag is given. In runLoad (cli/command/image/load.go:63-64), if the input flag is empty and stdin is an interactive terminal (dockerCli.In().IsTerminal()), the CLI refuses to proceed rather than block forever waiting for tar bytes that will never arrive. It is a guard against the command hanging indefinitely on an interactive TTY.","triggerScenarios":"Running `docker load` (or `docker image load`) in an interactive shell with no -i/--input flag and nothing piped or redirected into stdin, so stdin is a terminal device. Any invocation where opts.input == \"\" and IsTerminal() returns true.","commonSituations":"Typing `docker load myimage.tar` and forgetting the -i flag (the positional argument is ignored; '-' as stdin is not yet supported per the TODO in the code); running docker load from a script or CI step where the expected pipe/redirect was dropped; alias or wrapper scripts that swallow the redirection.","solutions":["Pass the archive with the flag: docker load -i myimage.tar","Or redirect/pipe the tar into stdin: docker load < myimage.tar, or gunzip -c img.tar.gz | docker load","In scripts, verify the upstream command actually produces the tar stream before piping to docker load"],"exampleFix":"# before\ndocker load myimage.tar   # positional arg ignored, stdin is a TTY -> error\n# after\ndocker load -i myimage.tar\n# or\ndocker load < myimage.tar","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","image-load","stdin","tty"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}