Skip to content

Commit 5506e4b

Browse files
committed
Merge pull request moby#4840 from vbatts/vbatts-load_from_input
docker load: add --input flag
2 parents abef5cb + 2517370 commit 5506e4b

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

api/client.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,6 +2100,8 @@ func (cli *DockerCli) CmdSave(args ...string) error {
21002100

21012101
func (cli *DockerCli) CmdLoad(args ...string) error {
21022102
cmd := cli.Subcmd("load", "", "Load an image from a tar archive on STDIN")
2103+
infile := cmd.String([]string{"i", "-input"}, "", "Read from a tar archive file, instead of STDIN")
2104+
21032105
if err := cmd.Parse(args); err != nil {
21042106
return err
21052107
}
@@ -2109,7 +2111,17 @@ func (cli *DockerCli) CmdLoad(args ...string) error {
21092111
return nil
21102112
}
21112113

2112-
if err := cli.stream("POST", "/images/load", cli.in, cli.out, nil); err != nil {
2114+
var (
2115+
input io.Reader = cli.in
2116+
err error
2117+
)
2118+
if *infile != "" {
2119+
input, err = os.Open(*infile)
2120+
if err != nil {
2121+
return err
2122+
}
2123+
}
2124+
if err := cli.stream("POST", "/images/load", input, cli.out, nil); err != nil {
21132125
return err
21142126
}
21152127
return nil

docs/sources/reference/commandline/cli.rst

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,32 @@ Known Issues (kill)
881881

882882
::
883883

884-
Usage: docker load < repository.tar
884+
Usage: docker load
885+
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 a file or the standard input stream.
891+
Restores both images and tags.
892+
893+
.. code-block:: bash
894+
895+
$ sudo docker images
896+
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
897+
$ sudo docker load < busybox.tar
898+
$ sudo docker images
899+
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
900+
busybox latest 769b9341d937 7 weeks ago 2.489 MB
901+
$ sudo docker load --input fedora.tar
902+
$ sudo docker images
903+
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
904+
busybox latest 769b9341d937 7 weeks ago 2.489 MB
905+
fedora rawhide 0d20aec6529d 7 weeks ago 387 MB
906+
fedora 20 58394af37342 7 weeks ago 385.5 MB
907+
fedora heisenbug 58394af37342 7 weeks ago 385.5 MB
908+
fedora latest 58394af37342 7 weeks ago 385.5 MB
885909
886-
Loads a tarred repository from the standard input stream.
887-
Restores both images and tags.
888910
889911
.. _cli_login:
890912

0 commit comments

Comments
 (0)