Browse Source

daemon: Ignore nonexistent containers when listing containers

The name/ID relationships are maintained separately from the memdb and
can be out of sync from any particular memdb snapshot. If a container
does not exist in the memdb, we must accept this as normal and not fail
the listing. This is consistent with what the code used to do before
memdb was introduced.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Aaron Lehmann 8 years ago
parent
commit
d257a63fb6
1 changed files with 6 additions and 4 deletions
  1. 6 4
      daemon/list.go

+ 6 - 4
daemon/list.go

@@ -162,11 +162,13 @@ func (daemon *Daemon) filterByNameIDMatches(view container.View, ctx *listContex
 	cntrs := make([]container.Snapshot, 0, len(matches))
 	cntrs := make([]container.Snapshot, 0, len(matches))
 	for id := range matches {
 	for id := range matches {
 		c, err := view.Get(id)
 		c, err := view.Get(id)
-		if err != nil {
-			return nil, err
-		}
-		if c != nil {
+		switch err.(type) {
+		case nil:
 			cntrs = append(cntrs, *c)
 			cntrs = append(cntrs, *c)
+		case container.NoSuchContainerError:
+			// ignore error
+		default:
+			return nil, err
 		}
 		}
 	}
 	}