Browse code

Fix tag output where image is not found.

Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)

Jessica Frazelle authored on 2014/11/21 08:09:09
Showing 1 changed files
... ...
@@ -2054,15 +2054,16 @@ func (cli *DockerCli) CmdTag(args ...string) error {
2054 2054
 }
2055 2055
 
2056 2056
 func (cli *DockerCli) pullImage(image string) error {
2057
+	return cli.pullImageCustomOut(image, cli.out)
2058
+}
2059
+
2060
+func (cli *DockerCli) pullImageCustomOut(image string, out io.Writer) error {
2061
+	v := url.Values{}
2057 2062
 	repos, tag := parsers.ParseRepositoryTag(image)
2063
+	// pull only the image tagged 'latest' if no tag was specified
2058 2064
 	if tag == "" {
2059 2065
 		tag = graph.DEFAULTTAG
2060 2066
 	}
2061
-	return cli.pullImageCustomOut(repos, tag, cli.out)
2062
-}
2063
-
2064
-func (cli *DockerCli) pullImageCustomOut(repos string, tag string, out io.Writer) error {
2065
-	v := url.Values{}
2066 2067
 	v.Set("fromImage", repos)
2067 2068
 	v.Set("tag", tag)
2068 2069
 
... ...
@@ -2150,14 +2151,14 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc
2150 2150
 	stream, statusCode, err := cli.call("POST", "/containers/create?"+containerValues.Encode(), mergedConfig, false)
2151 2151
 	//if image not found try to pull it
2152 2152
 	if statusCode == 404 {
2153
-		repos, tag := parsers.ParseRepositoryTag(config.Image)
2153
+		repo, tag := parsers.ParseRepositoryTag(config.Image)
2154 2154
 		if tag == "" {
2155 2155
 			tag = graph.DEFAULTTAG
2156 2156
 		}
2157
-		fmt.Fprintf(cli.err, "Unable to find image '%s:%s' locally\n", repos, tag)
2157
+		fmt.Fprintf(cli.err, "Unable to find image '%s:%s' locally\n", repo, tag)
2158 2158
 
2159 2159
 		// we don't want to write to stdout anything apart from container.ID
2160
-		if err = cli.pullImageCustomOut(repos, tag, cli.err); err != nil {
2160
+		if err = cli.pullImageCustomOut(config.Image, cli.err); err != nil {
2161 2161
 			return nil, err
2162 2162
 		}
2163 2163
 		// Retry