diff --git a/api.go b/api.go index 4c568d4bc7..59d88a7a21 100644 --- a/api.go +++ b/api.go @@ -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 diff --git a/commands.go b/commands.go index b2a4d3db13..656790624e 100644 --- a/commands.go +++ b/commands.go @@ -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 } } diff --git a/docs/sources/api/docker_remote_api_v1.4.rst b/docs/sources/api/docker_remote_api_v1.4.rst index 3ab5cdee0a..4f946e1e25 100644 --- a/docs/sources/api/docker_remote_api_v1.4.rst +++ b/docs/sources/api/docker_remote_api_v1.4.rst @@ -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