From 3f6182c38449ebb0980ae7660d3318e97787f62d Mon Sep 17 00:00:00 2001 From: Shijiang Wei Date: Mon, 30 Nov 2015 21:28:21 +0800 Subject: [PATCH] fix the panic when "ps -a" with dead containers Signed-off-by: Shijiang Wei --- api/handlers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/handlers.go b/api/handlers.go index 86e82e6c59..aff7529e0e 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -282,7 +282,11 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) { } // Apply filters. - if !filters.Match("name", strings.TrimPrefix(container.Names[0], "/")) { + if len(container.Names) > 0 { + if !filters.Match("name", strings.TrimPrefix(container.Names[0], "/")) { + continue + } + } else if len(filters["name"]) > 0 { continue } if !filters.Match("id", container.Id) {