Fix docker pull

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-05-12 13:04:19 +01:00
parent 91e78b73b9
commit 0ade84e151
2 changed files with 8 additions and 3 deletions

View File

@ -176,7 +176,13 @@ func dockerPull(image string, trustedPull bool) error {
return errors.New("could not initialize Docker API client")
}
if _, err := cli.ImagePull(context.Background(), image, types.ImagePullOptions{}); err != nil {
r, err := cli.ImagePull(context.Background(), image, types.ImagePullOptions{})
if err != nil {
return err
}
defer r.Close()
_, err = io.Copy(ioutil.Discard, r)
if err != nil {
return err
}
log.Debugf("docker pull: %s...Done", image)

View File

@ -9,7 +9,6 @@ import (
"strings"
log "github.com/Sirupsen/logrus"
"github.com/docker/docker/client"
)
// This uses Docker to convert a Docker image into a tarball. It would be an improvement if we
@ -104,7 +103,7 @@ func imageTar(image, prefix string, tw *tar.Writer, trust bool, pull bool) error
container, err := dockerCreate(image)
if err != nil {
// if the image wasn't found, pull it down. Bail on other errors.
if client.IsErrNotFound(err) {
if strings.Contains(err.Error(), "No such image") {
log.Infof("Pull image: %s", image)
err := dockerPull(image, trust)
if err != nil {