mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 07:13:41 +01:00
fix: fixes a possible race condition (#2762)
This commit is contained in:
@@ -67,6 +67,13 @@ func (s *ContainerStore) init(ctx context.Context) {
|
||||
stats := make(chan ContainerStat)
|
||||
s.statsCollector.Subscribe(ctx, stats)
|
||||
|
||||
if containers, err := s.client.ListContainers(); err == nil {
|
||||
for _, c := range containers {
|
||||
c := c // create a new variable to avoid capturing the loop variable
|
||||
s.containers.LoadOrStore(c.ID, &c)
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case event := <-events:
|
||||
|
||||
Reference in New Issue
Block a user