Detect images/containers conflicts in docker inspect
Upstream-commit: 5ec2fea6dd3360de326717ed01909b8fe9c39d0f Component: engine
This commit is contained in:
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,6 +761,7 @@ Inspect an image
|
||||
|
||||
:statuscode 200: no error
|
||||
:statuscode 404: no such image
|
||||
:statuscode 409: conflict between containers and images
|
||||
:statuscode 500: server error
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user