Skip to content

Commit bf6b447

Browse files
skanehirandeloof
authored andcommitted
fix: concurrent map writes when pulling
Signed-off-by: skanehira <sho19921005@gmail.com>
1 parent a96c305 commit bf6b447

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/compose/pull.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"fmt"
2525
"io"
2626
"strings"
27+
"sync"
2728
"time"
2829

2930
"github.com/compose-spec/compose-go/v2/types"
@@ -322,9 +323,12 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
322323
eg, ctx := errgroup.WithContext(ctx)
323324
eg.SetLimit(s.maxConcurrency)
324325
pulledImages := map[string]api.ImageSummary{}
326+
var mutex sync.Mutex
325327
for name, service := range needPull {
326328
eg.Go(func() error {
327329
id, err := s.pullServiceImage(ctx, service, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
330+
mutex.Lock()
331+
defer mutex.Unlock()
328332
pulledImages[name] = api.ImageSummary{
329333
ID: id,
330334
Repository: service.Image,

0 commit comments

Comments
 (0)