diff --git a/swarmpit/task/stats.go b/swarmpit/task/stats.go index 1b4d155..f9ef398 100644 --- a/swarmpit/task/stats.go +++ b/swarmpit/task/stats.go @@ -121,14 +121,15 @@ func ContainersUsage(cli *client.Client) (stats []ContainerStatus) { mux := &sync.Mutex{} for _, v := range resp { - go func() { + go func(v types.Container) { defer wg.Done() var stat = ContainerUsage(cli, v.ID); mux.Lock() stats = append(stats, stat) mux.Unlock() - }() + }(v) } + wg.Wait() return }