diff --git a/pkg/minikube/image/image.go b/pkg/minikube/image/image.go index 0199d3d97d..5a6cc82c1e 100644 --- a/pkg/minikube/image/image.go +++ b/pkg/minikube/image/image.go @@ -79,19 +79,23 @@ func DigestByGoLib(imgName string) string { return cf.Hex } -// WriteImageToDaemon write img to the local docker daemon -func WriteImageToDaemon(img string) error { - glog.Infof("Writing %s to local daemon", img) - +// ExistsImageInDaemon if img exist in local docker daemon +func ExistsImageInDaemon(img string) bool { // 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 + return true } } // Else, pull it + return false +} + +// WriteImageToDaemon write img to the local docker daemon +func WriteImageToDaemon(img string) error { + glog.Infof("Writing %s to local daemon", img) ref, err := name.ParseReference(img) if err != nil { return errors.Wrap(err, "parsing reference") diff --git a/pkg/minikube/node/cache.go b/pkg/minikube/node/cache.go index 5af6b2e303..dd01433ca8 100644 --- a/pkg/minikube/node/cache.go +++ b/pkg/minikube/node/cache.go @@ -100,12 +100,14 @@ func doCacheBinaries(k8sVersion string) error { // BeginDownloadKicArtifacts downloads the kic image + preload tarball, returns true if preload is available func beginDownloadKicArtifacts(g *errgroup.Group) { - out.T(out.Pulling, "Pulling base image ...") glog.Info("Beginning downloading kic artifacts") - g.Go(func() error { - glog.Infof("Downloading %s to local daemon", kic.BaseImage) - return image.WriteImageToDaemon(kic.BaseImage) - }) + if !image.ExistsImageInDaemon(kic.BaseImage) { + out.T(out.Pulling, "Pulling base image ...") + g.Go(func() error { + glog.Infof("Downloading %s to local daemon", kic.BaseImage) + return image.WriteImageToDaemon(kic.BaseImage) + }) + } } // WaitDownloadKicArtifacts blocks until the required artifacts for KIC are downloaded.