Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit d37dffe

Browse files
authored
Merge pull request #1513 from gtardif/fix_concurrent_map_writes
Avoid panic: concurrent map writes
2 parents d866491 + b96dc49 commit d37dffe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

local/compose/images.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"strings"
23+
"sync"
2324

2425
moby "github.com/docker/docker/api/types"
2526
"github.com/docker/docker/api/types/filters"
@@ -58,6 +59,7 @@ func (s *composeService) Images(ctx context.Context, projectName string, options
5859
}
5960

6061
images := map[string]moby.ImageInspect{}
62+
l := sync.Mutex{}
6163
eg, ctx := errgroup.WithContext(ctx)
6264
for _, img := range imageIDs {
6365
img := img
@@ -66,7 +68,9 @@ func (s *composeService) Images(ctx context.Context, projectName string, options
6668
if err != nil {
6769
return err
6870
}
71+
l.Lock()
6972
images[img] = inspect
73+
l.Unlock()
7074
return nil
7175
})
7276
}

0 commit comments

Comments
 (0)