From b96dc49bcbd2f02d224e9bd6c0d74f7497cd4cb6 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 8 Apr 2021 15:45:51 +0200 Subject: [PATCH] Avoid panic: concurrent map writes Signed-off-by: Guillaume Tardif --- local/compose/images.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/local/compose/images.go b/local/compose/images.go index e24168e9f..c6f33a9d9 100644 --- a/local/compose/images.go +++ b/local/compose/images.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "strings" + "sync" moby "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" @@ -58,6 +59,7 @@ func (s *composeService) Images(ctx context.Context, projectName string, options } images := map[string]moby.ImageInspect{} + l := sync.Mutex{} eg, ctx := errgroup.WithContext(ctx) for _, img := range imageIDs { img := img @@ -66,7 +68,9 @@ func (s *composeService) Images(ctx context.Context, projectName string, options if err != nil { return err } + l.Lock() images[img] = inspect + l.Unlock() return nil }) }