mirror of
https://github.com/docker/cli.git
synced 2026-01-16 20:22:36 +03:00
check if the image to delete isn't parent of another
Upstream-commit: d7673274d22140dc6dfa288351f1d4d2e2fa4b63 Component: engine
This commit is contained in:
@@ -729,6 +729,15 @@ func (srv *Server) ImageDelete(name string) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
// check is the image to delete isn't parent of another image
|
||||
images, _ := srv.runtime.graph.All()
|
||||
for _, image := range images {
|
||||
if imgParent, err := image.GetParent(); err == nil && imgParent != nil {
|
||||
if imgParent.Id == img.Id {
|
||||
return fmt.Errorf("Can't delete %s, otherwise %s will be broken", name, image.ShortId())
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := srv.runtime.graph.Delete(img.Id); err != nil {
|
||||
return fmt.Errorf("Error deleting image %s: %s", name, err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user