docker save: --output flag
for those that do not care to redirect stdout Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)
This commit is contained in:
parent
47470d299d
commit
5127732c79
1 changed files with 11 additions and 1 deletions
|
@ -2044,6 +2044,8 @@ func (cli *DockerCli) CmdCp(args ...string) error {
|
|||
|
||||
func (cli *DockerCli) CmdSave(args ...string) error {
|
||||
cmd := cli.Subcmd("save", "IMAGE", "Save an image to a tar archive (streamed to stdout)")
|
||||
outfile := cmd.String([]string{"o", "-output"}, "", "Write to an file, instead of STDOUT")
|
||||
|
||||
if err := cmd.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -2053,8 +2055,16 @@ func (cli *DockerCli) CmdSave(args ...string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
var output io.Writer = cli.out
|
||||
var err error
|
||||
if *outfile != "" {
|
||||
output, err = os.Create(*outfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
image := cmd.Arg(0)
|
||||
if err := cli.stream("GET", "/images/"+image+"/get", nil, cli.out, nil); err != nil {
|
||||
if err := cli.stream("GET", "/images/"+image+"/get", nil, output, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue