From bf6b4472634749d9344faaa67c6dc2c67aea3eed Mon Sep 17 00:00:00 2001 From: skanehira Date: Thu, 17 Apr 2025 11:13:23 +0900 Subject: [PATCH] fix: concurrent map writes when pulling Signed-off-by: skanehira --- pkg/compose/pull.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/compose/pull.go b/pkg/compose/pull.go index fbe82afcb..0e70c1892 100644 --- a/pkg/compose/pull.go +++ b/pkg/compose/pull.go @@ -24,6 +24,7 @@ import ( "fmt" "io" "strings" + "sync" "time" "github.com/compose-spec/compose-go/v2/types" @@ -322,9 +323,12 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types. eg, ctx := errgroup.WithContext(ctx) eg.SetLimit(s.maxConcurrency) pulledImages := map[string]api.ImageSummary{} + var mutex sync.Mutex for name, service := range needPull { eg.Go(func() error { id, err := s.pullServiceImage(ctx, service, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"]) + mutex.Lock() + defer mutex.Unlock() pulledImages[name] = api.ImageSummary{ ID: id, Repository: service.Image,