diff --git a/pkg/compose/pull.go b/pkg/compose/pull.go index 0e70c189213..946792d74e0 100644 --- a/pkg/compose/pull.go +++ b/pkg/compose/pull.go @@ -323,12 +323,13 @@ 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 + var imagesMutex sync.Mutex + var pulledImagesMutex 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() + pulledImagesMutex.Lock() + defer pulledImagesMutex.Unlock() pulledImages[name] = api.ImageSummary{ ID: id, Repository: service.Image, @@ -343,9 +344,11 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types. } err := eg.Wait() for i, service := range needPull { + imagesMutex.Lock() if pulledImages[i].ID != "" { images[service.Image] = pulledImages[i] } + imagesMutex.Unlock() } return err }, s.stdinfo())