From 84e1fdf35d9d6493d389a8e8be3ab41190004b30 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 24 Mar 2014 21:43:26 -0400 Subject: [PATCH 1/3] 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 (github: vbatts) --- api/client.go | 14 +++++++++++++- docs/sources/reference/commandline/cli.rst | 15 ++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/api/client.go b/api/client.go index f1a3f64f2a..f9e7445fd9 100644 --- a/api/client.go +++ b/api/client.go @@ -2075,6 +2075,8 @@ func (cli *DockerCli) CmdSave(args ...string) error { func (cli *DockerCli) CmdLoad(args ...string) error { cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN") + infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN") + if err := cmd.Parse(args); err != nil { return err } @@ -2084,7 +2086,17 @@ func (cli *DockerCli) CmdLoad(args ...string) error { return nil } - if err := cli.stream("POST", "/images/load", cli.in, cli.out, nil); err != nil { + var ( + input io.Reader = cli.in + err error + ) + if *infile != "" { + input, err = os.Open(*infile) + if err != nil { + return err + } + } + if err := cli.stream("POST", "/images/load", input, cli.out, nil); err != nil { return err } return nil diff --git a/docs/sources/reference/commandline/cli.rst b/docs/sources/reference/commandline/cli.rst index f4a5e0882f..2626280dd0 100644 --- a/docs/sources/reference/commandline/cli.rst +++ b/docs/sources/reference/commandline/cli.rst @@ -881,10 +881,19 @@ Known Issues (kill) :: - Usage: docker load < repository.tar + Usage: docker load - Loads a tarred repository from the standard input stream. - Restores both images and tags. + Load an image from a tar archive on STDIN + + -i, --input"": Read from a tar archive file, instead of STDIN + +Loads a tarred repository from the standard input stream. +Restores both images and tags. + +.. code-block:: bash + + $ sudo docker load < busybox.tar + $ sudo docker load --input busybox.tar .. _cli_login: From c6c7c03cddc852c42b9f047fbd5c2fb6cecf39eb Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 24 Mar 2014 23:31:59 -0400 Subject: [PATCH 2/3] docker load: doc clarification Docker-DCO-1.1-Signed-off-by: Vincent Batts (github: vbatts) --- docs/sources/reference/commandline/cli.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sources/reference/commandline/cli.rst b/docs/sources/reference/commandline/cli.rst index 2626280dd0..3c7bb47113 100644 --- a/docs/sources/reference/commandline/cli.rst +++ b/docs/sources/reference/commandline/cli.rst @@ -885,9 +885,9 @@ Known Issues (kill) Load an image from a tar archive on STDIN - -i, --input"": Read from a tar archive file, instead of STDIN + -i, --input="": Read from a tar archive file, instead of STDIN -Loads a tarred repository from the standard input stream. +Loads a tarred repository from a file or the standard input stream. Restores both images and tags. .. code-block:: bash From 2517370088ad11765f99d75c16b58e93fe18f85a Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 25 Mar 2014 08:30:59 -0400 Subject: [PATCH 3/3] docker load: added example of a multiple tag image Docker-DCO-1.1-Signed-off-by: Vincent Batts (github: vbatts) --- docs/sources/reference/commandline/cli.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/sources/reference/commandline/cli.rst b/docs/sources/reference/commandline/cli.rst index 3c7bb47113..687ce2f305 100644 --- a/docs/sources/reference/commandline/cli.rst +++ b/docs/sources/reference/commandline/cli.rst @@ -892,8 +892,21 @@ Restores both images and tags. .. code-block:: bash + $ sudo docker images + REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE $ sudo docker load < busybox.tar - $ sudo docker load --input busybox.tar + $ sudo docker images + REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE + busybox latest 769b9341d937 7 weeks ago 2.489 MB + $ sudo docker load --input fedora.tar + $ sudo docker images + REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE + busybox latest 769b9341d937 7 weeks ago 2.489 MB + fedora rawhide 0d20aec6529d 7 weeks ago 387 MB + fedora 20 58394af37342 7 weeks ago 385.5 MB + fedora heisenbug 58394af37342 7 weeks ago 385.5 MB + fedora latest 58394af37342 7 weeks ago 385.5 MB + .. _cli_login: