mirror of https://github.com/docker/cli.git
Validate docker-load receives a tar file
To load an image from a tar file, you can specify the tar file in the -i/--input option: docker load -i image_1.tar or using stdin: docker load < image_1.tar cat image_1.tat | docker load If the image file isn't given the `docker load` command gets stuck. To avoid that, the load makes sure the CLI input is not a terminal or the `--input` option was set. If not then an error message is shown. Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
This commit is contained in:
parent
faac177285
commit
fdbf29e1fa
|
@ -1,6 +1,7 @@
|
|||
package image
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
|
@ -49,6 +50,13 @@ func runLoad(dockerCli *command.DockerCli, opts loadOptions) error {
|
|||
defer file.Close()
|
||||
input = file
|
||||
}
|
||||
|
||||
// To avoid getting stuck, verify that a tar file is given either in
|
||||
// the input flag or through stdin and if not display an error message and exit.
|
||||
if opts.input == "" && dockerCli.In().IsTerminal() {
|
||||
return fmt.Errorf("requested load from stdin, but stdin is empty")
|
||||
}
|
||||
|
||||
if !dockerCli.Out().IsTerminal() {
|
||||
opts.quiet = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue