From 59b8a0f697355f1d404121f0c3e96c4957ac4608 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Fri, 2 Oct 2015 16:54:27 -0400 Subject: [PATCH] Don't let `Names` be null on GET /containers/JSON Fixes an issue where a `Dead` container has no names so the API returns `null` instead of an empty array. Signed-off-by: Brian Goff --- daemon/list.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/daemon/list.go b/daemon/list.go index c54df28f07..e2146d0f91 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -177,7 +177,7 @@ func (daemon *Daemon) foldFilter(config *ContainersConfig) (*listContext, error) } } - names := map[string][]string{} + names := make(map[string][]string) daemon.containerGraph().Walk("/", func(p string, e *graphdb.Entity) error { names[e.ID()] = append(names[e.ID()], p) return nil @@ -292,6 +292,10 @@ func (daemon *Daemon) transformContainer(container *Container, ctx *listContext) Names: ctx.names[container.ID], ImageID: container.ImageID, } + if newC.Names == nil { + // Dead containers will often have no name, so make sure the response isn't null + newC.Names = []string{} + } img, err := daemon.Repositories().LookupImage(container.Config.Image) if err != nil {