|
@@ -4,20 +4,22 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"io"
|
|
"io"
|
|
"net/url"
|
|
"net/url"
|
|
|
|
+ "os"
|
|
|
|
|
|
"github.com/docker/docker/opts"
|
|
"github.com/docker/docker/opts"
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
"github.com/docker/docker/pkg/parsers"
|
|
"github.com/docker/docker/pkg/parsers"
|
|
|
|
+ "github.com/docker/docker/pkg/urlutil"
|
|
"github.com/docker/docker/registry"
|
|
"github.com/docker/docker/registry"
|
|
)
|
|
)
|
|
|
|
|
|
// CmdImport creates an empty filesystem image, imports the contents of the tarball into the image, and optionally tags the image.
|
|
// CmdImport creates an empty filesystem image, imports the contents of the tarball into the image, and optionally tags the image.
|
|
//
|
|
//
|
|
-// The URL argument is the address of a tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) file. If the URL is '-', then the tar file is read from STDIN.
|
|
|
|
|
|
+// The URL argument is the address of a tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) file or a path to local file relative to docker client. If the URL is '-', then the tar file is read from STDIN.
|
|
//
|
|
//
|
|
-// Usage: docker import [OPTIONS] URL [REPOSITORY[:TAG]]
|
|
|
|
|
|
+// Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
|
|
func (cli *DockerCli) CmdImport(args ...string) error {
|
|
func (cli *DockerCli) CmdImport(args ...string) error {
|
|
- cmd := cli.Subcmd("import", []string{"URL|- [REPOSITORY[:TAG]]"}, "Create an empty filesystem image and import the contents of the\ntarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then\noptionally tag it.", true)
|
|
|
|
|
|
+ cmd := cli.Subcmd("import", []string{"file|URL|- [REPOSITORY[:TAG]]"}, "Create an empty filesystem image and import the contents of the\ntarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then\noptionally tag it.", true)
|
|
flChanges := opts.NewListOpts(nil)
|
|
flChanges := opts.NewListOpts(nil)
|
|
cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image")
|
|
cmd.Var(&flChanges, []string{"c", "-change"}, "Apply Dockerfile instruction to the created image")
|
|
cmd.Require(flag.Min, 1)
|
|
cmd.Require(flag.Min, 1)
|
|
@@ -36,7 +38,7 @@ func (cli *DockerCli) CmdImport(args ...string) error {
|
|
v.Add("changes", change)
|
|
v.Add("changes", change)
|
|
}
|
|
}
|
|
if cmd.NArg() == 3 {
|
|
if cmd.NArg() == 3 {
|
|
- fmt.Fprintf(cli.err, "[DEPRECATED] The format 'URL|- [REPOSITORY [TAG]]' has been deprecated. Please use URL|- [REPOSITORY[:TAG]]\n")
|
|
|
|
|
|
+ fmt.Fprintf(cli.err, "[DEPRECATED] The format 'file|URL|- [REPOSITORY [TAG]]' has been deprecated. Please use file|URL|- [REPOSITORY[:TAG]]\n")
|
|
v.Set("tag", cmd.Arg(2))
|
|
v.Set("tag", cmd.Arg(2))
|
|
}
|
|
}
|
|
|
|
|
|
@@ -52,6 +54,15 @@ func (cli *DockerCli) CmdImport(args ...string) error {
|
|
|
|
|
|
if src == "-" {
|
|
if src == "-" {
|
|
in = cli.in
|
|
in = cli.in
|
|
|
|
+ } else if !urlutil.IsURL(src) {
|
|
|
|
+ v.Set("fromSrc", "-")
|
|
|
|
+ file, err := os.Open(src)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ defer file.Close()
|
|
|
|
+ in = file
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
sopts := &streamOpts{
|
|
sopts := &streamOpts{
|