1
0
mirror of https://github.com/docker/docs.git synced 2026-11-06 12:54:24 +03:00

Cluster: Implemented support to return a list of all containers

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2014-11-10 16:25:09 -08:00
parent 74c23faeeb
commit 4a7068d94a

View File

@@ -38,3 +38,19 @@ func (c *Cluster) AddNode(n *Node) error {
c.nodes[n.ID] = n
return nil
}
// Containers returns all the containers running in the cluster.
func (c *Cluster) Containers() []*Container {
c.mux.Lock()
defer c.mux.Unlock()
out := []*Container{}
for _, n := range c.nodes {
containers := n.Containers()
for _, container := range containers {
out = append(out, container)
}
}
return out
}