Merge pull request #1810 from dotcloud/1798-inspect-fix

Detect images/containers conflicts in docker inspect
This commit is contained in:
Michael Crosby 2013-09-05 17:17:09 -07:00
commit f3d51bb3d5
3 changed files with 14 additions and 2 deletions

10
api.go
View File

@ -819,6 +819,11 @@ func getContainersByName(srv *Server, version float64, w http.ResponseWriter, r
if err != nil {
return err
}
_, err = srv.ImageInspect(name)
if err == nil {
return fmt.Errorf("Conflict between containers and images")
}
b, err := json.Marshal(container)
if err != nil {
return err
@ -837,6 +842,11 @@ func getImagesByName(srv *Server, version float64, w http.ResponseWriter, r *htt
if err != nil {
return err
}
_, err = srv.ContainerInspect(name)
if err == nil {
return fmt.Errorf("Conflict between containers and images")
}
b, err := json.Marshal(image)
if err != nil {
return err

View File

@ -577,7 +577,7 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
if err != nil {
obj, _, err = cli.call("GET", "/images/"+name+"/json", nil)
if err != nil {
fmt.Fprintf(cli.err, "%s\n", err)
fmt.Fprintf(cli.err, "No such image or container: %s\n", name)
continue
}
}

View File

@ -224,6 +224,7 @@ Inspect a container
:statuscode 200: no error
:statuscode 404: no such container
:statuscode 409: conflict between containers and images
:statuscode 500: server error
@ -760,7 +761,8 @@ Inspect an image
:statuscode 200: no error
:statuscode 404: no such image
:statuscode 500: server error
:statuscode 409: conflict between containers and images
:statuscode 500: server error
Get the history of an image