diff --git a/src/core/stats.go b/src/core/stats.go index 7a5c3e957..def874eb4 100644 --- a/src/core/stats.go +++ b/src/core/stats.go @@ -59,8 +59,9 @@ func (ds *dockerService) ListContainerStats( var wg sync.WaitGroup var stats = make([]*runtimeapi.ContainerStats, 0, len(listResp.Containers)) for _, container := range listResp.Containers { + container := container + wg.Add(1) go func() { - wg.Add(1) defer wg.Done() if containerStats, err := ds.getContainerStats(container.Id); err == nil && containerStats != nil { mtx.Lock()