mirror of https://github.com/docker/compose.git
Merge pull request #1513 from gtardif/fix_concurrent_map_writes
Avoid panic: concurrent map writes
This commit is contained in:
commit
d37dffe5e2
|
@ -20,6 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
moby "github.com/docker/docker/api/types"
|
moby "github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"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{}
|
images := map[string]moby.ImageInspect{}
|
||||||
|
l := sync.Mutex{}
|
||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
for _, img := range imageIDs {
|
for _, img := range imageIDs {
|
||||||
img := img
|
img := img
|
||||||
|
@ -66,7 +68,9 @@ func (s *composeService) Images(ctx context.Context, projectName string, options
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
l.Lock()
|
||||||
images[img] = inspect
|
images[img] = inspect
|
||||||
|
l.Unlock()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue