Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "docker.io/" prefixing when listing Docker images #19344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/docker"
"k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/image"
"k8s.io/minikube/pkg/minikube/style"
"k8s.io/minikube/pkg/minikube/sysinit"
)
Expand Down Expand Up @@ -292,7 +291,7 @@ func (r *Docker) ListImages(ListImagesOptions) ([]ListImage, error) {
result = append(result, ListImage{
ID: strings.TrimPrefix(jsonImage.ID, "sha256:"),
RepoDigests: []string{},
RepoTags: []string{addDockerIO(repoTag)},
RepoTags: []string{repoTag},
Size: fmt.Sprintf("%d", size),
})
}
Expand Down Expand Up @@ -678,15 +677,13 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool {
}
preloadedImages := map[string]struct{}{}
for _, i := range strings.Split(rr.Stdout.String(), "\n") {
i = image.TrimDockerIO(i)
preloadedImages[i] = struct{}{}
}

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

// Make sure images == imgs
for _, i := range images {
i = image.TrimDockerIO(i)
if _, ok := preloadedImages[i]; !ok {
klog.Infof("%s wasn't preloaded", i)
return false
Expand All @@ -695,29 +692,6 @@ func dockerImagesPreloaded(runner command.Runner, images []string) bool {
return true
}

// Add docker.io prefix
func addDockerIO(name string) string {
var reg, usr, img string
p := strings.SplitN(name, "/", 2)
if len(p) > 1 && strings.Contains(p[0], ".") {
reg = p[0]
img = p[1]
} else {
reg = "docker.io"
img = name
p = strings.SplitN(img, "/", 2)
if len(p) > 1 {
usr = p[0]
img = p[1]
} else {
usr = "library"
img = name
}
return reg + "/" + usr + "/" + img
}
return reg + "/" + img
}

func dockerBoundToContainerd(runner command.Runner) bool {
// NOTE: assumes systemd
rr, err := runner.RunCmd(exec.Command("sudo", "systemctl", "cat", "docker.service"))
Expand Down
2 changes: 1 addition & 1 deletion pkg/minikube/download/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func ImageExistsInDaemon(img string) bool {
klog.Warningf("failed to list docker images: %v", err)
return false
}
if !strings.Contains(string(output), image.TrimDockerIO(img)) {
if !strings.Contains(string(output), img) {
return false
}
correctArch, err := isImageCorrectArch(img)
Expand Down
6 changes: 0 additions & 6 deletions pkg/minikube/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,3 @@ func normalizeTagName(image string) string {
}
return base + ":" + tag
}

// Remove docker.io prefix since it won't be included in image names
// when we call `docker images`.
func TrimDockerIO(name string) string {
return strings.TrimPrefix(name, "docker.io/")
}
Loading