From aaaeb84ac62db4b82721129c393f8ad9ffa67128 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 26 Aug 2016 10:02:10 -0700 Subject: [PATCH] Check for non-nil container after match There can be a race between getting the container ids for matches and getting the actual container. This makes sure that we check that the container returned by `Get` is non-nil before adding it to the list of matches. Fixes #25991 Signed-off-by: Michael Crosby (cherry picked from commit a020ec4c8b476a814eb137e216fe9d723524fc3b) Signed-off-by: Victor Vieux --- daemon/list.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/list.go b/daemon/list.go index 6d86cd3b48..e55a38aa04 100644 --- a/daemon/list.go +++ b/daemon/list.go @@ -157,7 +157,9 @@ func (daemon *Daemon) filterByNameIDMatches(ctx *listContext) []*container.Conta cntrs := make([]*container.Container, 0, len(matches)) for id := range matches { - cntrs = append(cntrs, daemon.containers.Get(id)) + if c := daemon.containers.Get(id); c != nil { + cntrs = append(cntrs, c) + } } // Restore sort-order after filtering