Skip to content

ignore docker rmi fail with container image used by running container #17805

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ func removeExistingImage(r cruntime.Manager, src string, imgName string) error {
}

errStr := strings.ToLower(err.Error())
if strings.Contains(errStr, "is using its referenced image") {
klog.Warningf("Image %s is being used by a running container, skipping deletion, it would be replaced later", imgName)
return nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain why would we wanna return nil ? and not return an error ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the upstream error is throw by docker image rm, but docker will failed to untag the image if there is a running container using this image.

but that's fine, the next steps would load image and replace the tag with new image.

so we could ignore this error safely, also complete the origin purpose:

  • minikube image load should replace the old existing image

}

if !strings.Contains(errStr, "no such image") {
return errors.Wrap(err, "removing image")
}
Expand Down