github.com/tsuna/docker@v1.7.0-rc3/api/client/load.go (about) 1 package client 2 3 import ( 4 "io" 5 "os" 6 7 flag "github.com/docker/docker/pkg/mflag" 8 ) 9 10 // CmdLoad loads an image from a tar archive. 11 // 12 // The tar archive is read from STDIN by default, or from a tar archive file. 13 // 14 // Usage: docker load [OPTIONS] 15 func (cli *DockerCli) CmdLoad(args ...string) error { 16 cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN", true) 17 infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN") 18 cmd.Require(flag.Exact, 0) 19 20 cmd.ParseFlags(args, true) 21 22 var ( 23 input io.Reader = cli.in 24 err error 25 ) 26 if *infile != "" { 27 input, err = os.Open(*infile) 28 if err != nil { 29 return err 30 } 31 } 32 sopts := &streamOpts{ 33 rawTerminal: true, 34 in: input, 35 out: cli.out, 36 } 37 if err := cli.stream("POST", "/images/load", sopts); err != nil { 38 return err 39 } 40 return nil 41 }