From 5d1628113a97e4fae56ec308645845c1db0a2139 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Mon, 2 Mar 2020 17:30:26 -0800 Subject: [PATCH] use docker command line to check if image exists, since it is much faster than go-containerregistry --- pkg/minikube/image/image.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index c393e9526407..a14ad85f71a1 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -20,6 +20,7 @@ import ( "context" "io/ioutil" "os" + "os/exec" "path/filepath" "runtime" "strings" @@ -86,14 +87,18 @@ func WriteImageToDaemon(img string) error { return errors.Wrap(err, "point host docker-daemon") } // Check if image exists locally + cmd := exec.Command("docker", "images", "--format", "{{.Repository}}:{{.Tag}}@{{.Digest}}") + if output, err := cmd.Output(); err == nil { + if strings.Contains(string(output), img) { + glog.Infof("Found %s in local docker daemon, skipping pull", img) + return nil + } + } + // Else, pull it ref, err := name.ParseReference(img) if err != nil { return errors.Wrap(err, "parsing reference") } - if _, err := daemon.Image(ref); err == nil { - glog.Infof("Found %s in local docker daemon, skipping pull", img) - return nil - } i, err := remote.Image(ref) if err != nil { return errors.Wrap(err, "getting remote image")