diff --git a/pkg/minikube/machine/cache_images.go b/pkg/minikube/machine/cache_images.go index 4e2a349cbb..db7f901252 100644 --- a/pkg/minikube/machine/cache_images.go +++ b/pkg/minikube/machine/cache_images.go @@ -17,7 +17,10 @@ limitations under the License. package machine import ( + "bytes" + "io" "io/ioutil" + "log" "os" "os/exec" "path" @@ -288,6 +291,21 @@ func getDstPath(image, dst string) (string, error) { // CacheImage caches an image func CacheImage(image, dst string) error { + // There are go-containerregistry calls here that result in + // ugly log messages getting printed to stdout. Capture + // stdout instead and writing it to info. + r, w, err := os.Pipe() + if err != nil { + return errors.Wrap(err, "opening writing buffer") + } + log.SetOutput(w) + defer func() { + log.SetOutput(os.Stdout) + var buf bytes.Buffer + io.Copy(&buf, r) + glog.Infof(buf.String()) + }() + glog.Infof("Attempting to cache image: %s at %s\n", image, dst) if _, err := os.Stat(dst); err == nil { return nil