From d9670f427522fc847313ad1b94b1e288dafe7690 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 28 May 2013 15:06:26 +0000 Subject: [PATCH 1/3] invert status created --- commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 6c4dcd14d6..f68bfbad53 100644 --- a/commands.go +++ b/commands.go @@ -806,9 +806,9 @@ func (cli *DockerCli) CmdPs(args ...string) error { for _, out := range outs { if !*quiet { if *noTrunc { - fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", out.Id, out.Image, out.Command, out.Status, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Ports) + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", out.Id, out.Image, out.Command, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports) } else { - fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", utils.TruncateId(out.Id), out.Image, utils.Trunc(out.Command, 20), out.Status, utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Ports) + fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s ago\t%s\n", utils.TruncateId(out.Id), out.Image, utils.Trunc(out.Command, 20), utils.HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))), out.Status, out.Ports) } } else { if *noTrunc { From 4f9443927e8bc8a724b43afae6cf7a183cd9acd0 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 28 May 2013 16:08:05 +0000 Subject: [PATCH 2/3] rename containers/ps to containers/json --- api.go | 5 +++-- api_test.go | 6 +++--- commands.go | 2 +- docs/sources/api/docker_remote_api.rst | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/api.go b/api.go index 3164a886f6..d23b8901b9 100644 --- a/api.go +++ b/api.go @@ -206,7 +206,7 @@ func getContainersChanges(srv *Server, version float64, w http.ResponseWriter, r return nil } -func getContainersPs(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { +func getContainersJson(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error { if err := parseForm(r); err != nil { return err } @@ -627,7 +627,8 @@ func ListenAndServe(addr string, srv *Server, logging bool) error { "/images/search": getImagesSearch, "/images/{name:.*}/history": getImagesHistory, "/images/{name:.*}/json": getImagesByName, - "/containers/ps": getContainersPs, + "/containers/ps": getContainersJson, + "/containers/json": getContainersJson, "/containers/{name:.*}/export": getContainersExport, "/containers/{name:.*}/changes": getContainersChanges, "/containers/{name:.*}/json": getContainersByName, diff --git a/api_test.go b/api_test.go index 06413e1303..f94ba23fa0 100644 --- a/api_test.go +++ b/api_test.go @@ -318,7 +318,7 @@ func TestGetImagesByName(t *testing.T) { } } -func TestGetContainersPs(t *testing.T) { +func TestGetContainersJson(t *testing.T) { runtime, err := newTestRuntime() if err != nil { t.Fatal(err) @@ -336,13 +336,13 @@ func TestGetContainersPs(t *testing.T) { } defer runtime.Destroy(container) - req, err := http.NewRequest("GET", "/containers?quiet=1&all=1", nil) + req, err := http.NewRequest("GET", "/containers/json?all=1", nil) if err != nil { t.Fatal(err) } r := httptest.NewRecorder() - if err := getContainersPs(srv, API_VERSION, r, req, nil); err != nil { + if err := getContainersJson(srv, API_VERSION, r, req, nil); err != nil { t.Fatal(err) } containers := []ApiContainers{} diff --git a/commands.go b/commands.go index 6c4dcd14d6..05d66bce20 100644 --- a/commands.go +++ b/commands.go @@ -788,7 +788,7 @@ func (cli *DockerCli) CmdPs(args ...string) error { v.Set("before", *before) } - body, _, err := cli.call("GET", "/containers/ps?"+v.Encode(), nil) + body, _, err := cli.call("GET", "/containers/json?"+v.Encode(), nil) if err != nil { return err } diff --git a/docs/sources/api/docker_remote_api.rst b/docs/sources/api/docker_remote_api.rst index 0dcf842738..bd87dc7a03 100644 --- a/docs/sources/api/docker_remote_api.rst +++ b/docs/sources/api/docker_remote_api.rst @@ -24,7 +24,7 @@ Docker Remote API List containers *************** -.. http:get:: /containers/ps +.. http:get:: /containers/json List containers @@ -32,7 +32,7 @@ List containers .. sourcecode:: http - GET /containers/ps?all=1&before=8dfafdbc3a40 HTTP/1.1 + GET /containers/json?all=1&before=8dfafdbc3a40 HTTP/1.1 **Example response**: From e5fa4a4956393afc473539710e2a4b7297eb6ebf Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 28 May 2013 16:19:12 +0000 Subject: [PATCH 3/3] return 404 on no such containers in /attach --- api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api.go b/api.go index 3164a886f6..581cc84d1d 100644 --- a/api.go +++ b/api.go @@ -541,6 +541,10 @@ func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r } name := vars["name"] + if _, err := srv.ContainerInspect(name); err != nil { + return err + } + in, out, err := hijackServer(w) if err != nil { return err