mirror of
https://github.com/docker/compose.git
synced 2025-07-27 07:34:10 +02:00
run ContainerWait in background so we catch container exit
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
83475569e6
commit
9af5ea4b6a
@ -83,7 +83,7 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis
|
|||||||
s.attachContainer(ctx, container, listener, project) // nolint: errcheck
|
s.attachContainer(ctx, container, listener, project) // nolint: errcheck
|
||||||
delete(crashed, event.Container)
|
delete(crashed, event.Container)
|
||||||
|
|
||||||
s.waitContainer(ctx, container, listener)
|
s.waitContainer(container, listener)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -51,14 +51,14 @@ func (s *composeService) Start(ctx context.Context, project *types.Project, opti
|
|||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
c := c
|
c := c
|
||||||
go func() {
|
go func() {
|
||||||
s.waitContainer(ctx, c, options.Attach)
|
s.waitContainer(c, options.Attach)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *composeService) waitContainer(ctx context.Context, c moby.Container, listener compose.ContainerEventListener) {
|
func (s *composeService) waitContainer(c moby.Container, listener compose.ContainerEventListener) {
|
||||||
statusC, errC := s.apiClient.ContainerWait(ctx, c.ID, container.WaitConditionNotRunning)
|
statusC, errC := s.apiClient.ContainerWait(context.Background(), c.ID, container.WaitConditionNotRunning)
|
||||||
name := getContainerNameWithoutProject(c)
|
name := getContainerNameWithoutProject(c)
|
||||||
select {
|
select {
|
||||||
case status := <-statusC:
|
case status := <-statusC:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user