Don't write pull output to stdout on container creating

Fixes #8632

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
Upstream-commit: ff325bcb2feb501c2287ecb305644b003784f726
Component: engine
This commit is contained in:
Alexandr Morozov
2014-10-17 11:06:05 -07:00
committed by Tibor Vass
parent 7634be83d9
commit 540f32c0f8
2 changed files with 23 additions and 2 deletions

View File

@ -1986,6 +1986,10 @@ 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
@ -2014,7 +2018,7 @@ func (cli *DockerCli) pullImage(image string) error {
registryAuthHeader := []string{
base64.URLEncoding.EncodeToString(buf),
}
if err = cli.stream("POST", "/images/create?"+v.Encode(), nil, cli.out, map[string][]string{"X-Registry-Auth": registryAuthHeader}); err != nil {
if err = cli.stream("POST", "/images/create?"+v.Encode(), nil, out, map[string][]string{"X-Registry-Auth": registryAuthHeader}); err != nil {
return err
}
return nil
@ -2081,7 +2085,8 @@ func (cli *DockerCli) createContainer(config *runconfig.Config, hostConfig *runc
if statusCode == 404 {
fmt.Fprintf(cli.err, "Unable to find image '%s' locally\n", config.Image)
if err = cli.pullImage(config.Image); err != nil {
// we don't want to write to stdout anything apart from container.ID
if err = cli.pullImageCustomOut(config.Image, cli.err); err != nil {
return nil, err
}
// Retry