Skip to content

Commit 19b7168

Browse files
committed
fix: trim docker.io to prevent always writing to daemon
Signed-off-by: Yue Yang <[email protected]>
1 parent d8c4920 commit 19b7168

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Diff for: pkg/minikube/cruntime/docker.go

+2-9
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,15 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool {
604604
}
605605
preloadedImages := map[string]struct{}{}
606606
for _, i := range strings.Split(rr.Stdout.String(), "\n") {
607-
i = trimDockerIO(i)
607+
i = TrimDockerIO(i)
608608
preloadedImages[i] = struct{}{}
609609
}
610610

611611
klog.Infof("Got preloaded images: %s", rr.Output())
612612

613613
// Make sure images == imgs
614614
for _, i := range images {
615-
i = trimDockerIO(i)
615+
i = TrimDockerIO(i)
616616
if _, ok := preloadedImages[i]; !ok {
617617
klog.Infof("%s wasn't preloaded", i)
618618
return false
@@ -644,13 +644,6 @@ func addDockerIO(name string) string {
644644
return reg + "/" + img
645645
}
646646

647-
// Remove docker.io prefix since it won't be included in images names
648-
// when we call 'docker images'
649-
func trimDockerIO(name string) string {
650-
name = strings.TrimPrefix(name, "docker.io/")
651-
return name
652-
}
653-
654647
func dockerBoundToContainerd(runner command.Runner) bool {
655648
// NOTE: assumes systemd
656649
rr, err := runner.RunCmd(exec.Command("sudo", "systemctl", "cat", "docker.service"))

Diff for: pkg/minikube/download/image.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,20 @@ func ImageExistsInCache(img string) bool {
6969

7070
var checkImageExistsInCache = ImageExistsInCache
7171

72+
// Remove docker.io prefix since it won't be included in images names
73+
// when we call 'docker images'
74+
func TrimDockerIO(name string) string {
75+
name = strings.TrimPrefix(name, "docker.io/")
76+
return name
77+
}
78+
7279
// ImageExistsInDaemon if img exist in local docker daemon
7380
func ImageExistsInDaemon(img string) bool {
7481
// Check if image exists locally
7582
klog.Infof("Checking for %s in local docker daemon", img)
7683
cmd := exec.Command("docker", "images", "--format", "{{.Repository}}:{{.Tag}}@{{.Digest}}")
7784
if output, err := cmd.Output(); err == nil {
78-
if strings.Contains(string(output), img) {
85+
if strings.Contains(string(output), TrimDockerIO(img)) {
7986
klog.Infof("Found %s in local docker daemon, skipping pull", img)
8087
return true
8188
}

0 commit comments

Comments
 (0)