mirror of https://github.com/docker/docs.git
Cluster: Implemented support to return a list of all containers
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
74c23faeeb
commit
4a7068d94a
16
cluster.go
16
cluster.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue