mirror of https://github.com/docker/compose.git
ContainerStart must run sequentially for engine to assing distinct ports within configured range
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
8f991a20db
commit
3ee2ab87bb
|
@ -721,21 +721,17 @@ func (s *composeService) startService(ctx context.Context, project *types.Projec
|
||||||
}
|
}
|
||||||
|
|
||||||
w := progress.ContextWriter(ctx)
|
w := progress.ContextWriter(ctx)
|
||||||
eg, ctx := errgroup.WithContext(ctx)
|
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
if container.State == ContainerRunning {
|
if container.State == ContainerRunning {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
container := container
|
|
||||||
eg.Go(func() error {
|
|
||||||
eventName := getContainerProgressName(container)
|
eventName := getContainerProgressName(container)
|
||||||
w.Event(progress.StartingEvent(eventName))
|
w.Event(progress.StartingEvent(eventName))
|
||||||
err := s.apiClient().ContainerStart(ctx, container.ID, moby.ContainerStartOptions{})
|
err := s.apiClient().ContainerStart(ctx, container.ID, moby.ContainerStartOptions{})
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
w.Event(progress.StartedEvent(eventName))
|
w.Event(progress.StartedEvent(eventName))
|
||||||
}
|
}
|
||||||
return err
|
return nil
|
||||||
})
|
|
||||||
}
|
|
||||||
return eg.Wait()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,3 +56,13 @@ func TestUpExitCodeFrom(t *testing.T) {
|
||||||
|
|
||||||
c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans")
|
c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPortRange(t *testing.T) {
|
||||||
|
c := NewParallelCLI(t)
|
||||||
|
const projectName = "e2e-port-range"
|
||||||
|
|
||||||
|
res := c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/port-range/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||||
|
res.Assert(t, icmd.Success)
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans")
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
services:
|
||||||
|
a:
|
||||||
|
image: nginx:alpine
|
||||||
|
scale: 5
|
||||||
|
ports:
|
||||||
|
- "6005-6015:80"
|
Loading…
Reference in New Issue