mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge fixes + cleanup
This commit is contained in:
parent
2ae8aaa106
commit
db1e965b65
1 changed files with 28 additions and 34 deletions
18
server.go
18
server.go
|
@ -699,15 +699,16 @@ func (srv *Server) ImageDelete(name string) error {
|
||||||
img, err := srv.runtime.repositories.LookupImage(name)
|
img, err := srv.runtime.repositories.LookupImage(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("No such image: %s", name)
|
return fmt.Errorf("No such image: %s", name)
|
||||||
} else {
|
}
|
||||||
tag := ""
|
var tag string
|
||||||
if strings.Contains(name, ":") {
|
if strings.Contains(name, ":") {
|
||||||
nameParts := strings.Split(name, ":")
|
nameParts := strings.Split(name, ":")
|
||||||
name = nameParts[0]
|
name = nameParts[0]
|
||||||
tag = nameParts[1]
|
tag = nameParts[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the images is referenced several times
|
// if the images is referenced several times
|
||||||
Debugf("Image %s referenced %d times", img.Id, len(srv.runtime.repositories.ById()[img.Id]))
|
utils.Debugf("Image %s referenced %d times", img.Id, len(srv.runtime.repositories.ById()[img.Id]))
|
||||||
if len(srv.runtime.repositories.ById()[img.Id]) > 1 {
|
if len(srv.runtime.repositories.ById()[img.Id]) > 1 {
|
||||||
// if it's repo:tag, try to delete the tag (docker rmi base:latest)
|
// if it's repo:tag, try to delete the tag (docker rmi base:latest)
|
||||||
if tag != "" {
|
if tag != "" {
|
||||||
|
@ -715,17 +716,11 @@ func (srv *Server) ImageDelete(name string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else {
|
}
|
||||||
// check if the image is referenced in another repo (base and user/base are the same, docker rmi user/base)
|
// check if the image is referenced in another repo (base and user/base are the same, docker rmi user/base)
|
||||||
var other bool
|
|
||||||
for _, repoTag := range srv.runtime.repositories.ById()[img.Id] {
|
for _, repoTag := range srv.runtime.repositories.ById()[img.Id] {
|
||||||
if !strings.Contains(repoTag, name+":") {
|
if !strings.Contains(repoTag, name+":") {
|
||||||
other = true
|
// if found in another repo, delete the repo, otherwie delete the whole image (docker rmi base)
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if found in another repo, delete the repo, other delete the whole image (docker rmi base)
|
|
||||||
if other {
|
|
||||||
if err := srv.runtime.repositories.Delete(name, "", img.Id); err != nil {
|
if err := srv.runtime.repositories.Delete(name, "", img.Id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -739,7 +734,6 @@ func (srv *Server) ImageDelete(name string) error {
|
||||||
if err := srv.runtime.repositories.Delete(name, tag, img.Id); err != nil {
|
if err := srv.runtime.repositories.Delete(name, tag, img.Id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue