Browse code

docker load: add --input flag

for those that do not care to read from redirected stdin

Docker-DCO-1.1-Signed-off-by: Vincent Batts <vbatts@redhat.com> (github: vbatts)

Vincent Batts authored on 2014/03/25 10:43:26
Showing 2 changed files
... ...
@@ -2075,6 +2075,8 @@ func (cli *DockerCli) CmdSave(args ...string) error {
2075 2075
 
2076 2076
 func (cli *DockerCli) CmdLoad(args ...string) error {
2077 2077
 	cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN")
2078
+	infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN")
2079
+
2078 2080
 	if err := cmd.Parse(args); err != nil {
2079 2081
 		return err
2080 2082
 	}
... ...
@@ -2084,7 +2086,17 @@ func (cli *DockerCli) CmdLoad(args ...string) error {
2084 2084
 		return nil
2085 2085
 	}
2086 2086
 
2087
-	if err := cli.stream("POST", "/images/load", cli.in, cli.out, nil); err != nil {
2087
+	var (
2088
+		input io.Reader = cli.in
2089
+		err   error
2090
+	)
2091
+	if *infile != "" {
2092
+		input, err = os.Open(*infile)
2093
+		if err != nil {
2094
+			return err
2095
+		}
2096
+	}
2097
+	if err := cli.stream("POST", "/images/load", input, cli.out, nil); err != nil {
2088 2098
 		return err
2089 2099
 	}
2090 2100
 	return nil
... ...
@@ -881,10 +881,19 @@ Known Issues (kill)
881 881
 
882 882
 ::
883 883
 
884
-    Usage: docker load < repository.tar
884
+    Usage: docker load 
885 885
 
886
-    Loads a tarred repository from the standard input stream.
887
-    Restores both images and tags.
886
+    Load an image from a tar archive on STDIN
887
+
888
+      -i, --input"": Read from a tar archive file, instead of STDIN
889
+
890
+Loads a tarred repository from the standard input stream.
891
+Restores both images and tags.
892
+
893
+.. code-block:: bash
894
+
895
+   $ sudo docker load < busybox.tar
896
+   $ sudo docker load --input busybox.tar
888 897
 
889 898
 .. _cli_login:
890 899