Skip to content

Commit e46c47c

Browse files
committed
run ContainerStart sequentially
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 2352a4a commit e46c47c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

pkg/compose/convergence.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,14 @@ func (s *composeService) recreateContainer(ctx context.Context, project *types.P
650650
return created, err
651651
}
652652

653+
// force sequential calls to ContainerStart to prevent race condition in engine assigning ports from ranges
654+
var startMx sync.Mutex
655+
653656
func (s *composeService) startContainer(ctx context.Context, ctr containerType.Summary) error {
654657
w := progress.ContextWriter(ctx)
655658
w.Event(progress.NewEvent(getContainerProgressName(ctr), progress.Working, "Restart"))
659+
startMx.Lock()
660+
defer startMx.Unlock()
656661
err := s.apiClient().ContainerStart(ctx, ctr.ID, containerType.StartOptions{})
657662
if err != nil {
658663
return err

pkg/e2e/fixtures/port-range/compose.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@ services:
33
image: nginx:alpine
44
scale: 5
55
ports:
6-
- "6005-6015:80"
6+
- "6005-6015:80"
7+
8+
b:
9+
image: nginx:alpine
10+
ports:
11+
- 80
12+
13+
c:
14+
image: nginx:alpine
15+
ports:
16+
- 80

0 commit comments

Comments
 (0)