From 7a7890950d59abf7bc4f826c605289e1d7586390 Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Tue, 4 Nov 2014 11:46:53 +0800 Subject: [PATCH 1/2] Fix create container output messages. Signed-off-by: Lei Jitang Signed-off-by: Jessica Frazelle --- api/client/commands.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/api/client/commands.go b/api/client/commands.go index d0a0792399..39352c8b89 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -2054,16 +2054,15 @@ func (cli *DockerCli) CmdTag(args ...string) error { } func (cli *DockerCli) pullImage(image string) error { - return cli.pullImageCustomOut(image, cli.out) -} - -func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error { - v := url.Values{} repos, tag := parsers.ParseRepositoryTag(image) - // pull only the image tagged 'latest' if no tag was specified if tag == "" { tag = graph.DEFAULTTAG } + return cli.pullImageCustomOut(repos, tag, cli.out) +} + +func (cli *DockerCli) pullImageCustomOut(repos string, tag string, out io.Writer) error { + v := url.Values{} v.Set("fromImage", repos) v.Set("tag", tag) @@ -2151,10 +2150,14 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc stream, statusCode, err := cli.call("POST", "/containers/create?"+containerValues.Encode(), mergedConfig, false) //if image not found try to pull it if statusCode == 404 { - fmt.Fprintf(cli.err, "Unable to find image '%s' locally\n", config.Image) + repos, tag := parsers.ParseRepositoryTag(config.Image) + if tag == "" { + tag = graph.DEFAULTTAG + } + fmt.Fprintf(cli.err, "Unable to find image '%s:%s' locally\n", repos, tag) // we don't want to write to stdout anything apart from container.ID - if err = cli.pullImageCustomOut(config.Image, cli.err); err != nil { + if err = cli.pullImageCustomOut(repos, tag, cli.err); err != nil { return nil, err } // Retry From e527be1f14eda5a3d9077517a0398d85c4d7fac6 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Thu, 20 Nov 2014 15:09:09 -0800 Subject: [PATCH 2/2] Fix tag output where image is not found. Docker-DCO-1.1-Signed-off-by: Jessica Frazelle (github: jfrazelle) --- api/client/commands.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/api/client/commands.go b/api/client/commands.go index 39352c8b89..8cdeb454d0 100644 --- a/api/client/commands.go +++ b/api/client/commands.go @@ -2054,15 +2054,16 @@ func (cli *DockerCli) CmdTag(args ...string) error { } func (cli *DockerCli) pullImage(image string) error { + return cli.pullImageCustomOut(image, cli.out) +} + +func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error { + v := url.Values{} repos, tag := parsers.ParseRepositoryTag(image) + // pull only the image tagged 'latest' if no tag was specified if tag == "" { tag = graph.DEFAULTTAG } - return cli.pullImageCustomOut(repos, tag, cli.out) -} - -func (cli *DockerCli) pullImageCustomOut(repos string, tag string, out io.Writer) error { - v := url.Values{} v.Set("fromImage", repos) v.Set("tag", tag) @@ -2150,14 +2151,14 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc stream, statusCode, err := cli.call("POST", "/containers/create?"+containerValues.Encode(), mergedConfig, false) //if image not found try to pull it if statusCode == 404 { - repos, tag := parsers.ParseRepositoryTag(config.Image) + repo, tag := parsers.ParseRepositoryTag(config.Image) if tag == "" { tag = graph.DEFAULTTAG } - fmt.Fprintf(cli.err, "Unable to find image '%s:%s' locally\n", repos, tag) + fmt.Fprintf(cli.err, "Unable to find image '%s:%s' locally\n", repo, tag) // we don't want to write to stdout anything apart from container.ID - if err = cli.pullImageCustomOut(repos, tag, cli.err); err != nil { + if err = cli.pullImageCustomOut(config.Image, cli.err); err != nil { return nil, err } // Retry