run ContainerWait in background so we catch container exit

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-03-22 16:31:10 +01:00
parent 83475569e6
commit 9af5ea4b6a
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
2 changed files with 4 additions and 4 deletions

View File

@ -83,7 +83,7 @@ func (s *composeService) attach(ctx context.Context, project *types.Project, lis
s.attachContainer(ctx, container, listener, project) // nolint: errcheck
delete(crashed, event.Container)
s.waitContainer(ctx, container, listener)
s.waitContainer(container, listener)
}
return nil
},

View File

@ -51,14 +51,14 @@ func (s *composeService) Start(ctx context.Context, project *types.Project, opti
for _, c := range containers {
c := c
go func() {
s.waitContainer(ctx, c, options.Attach)
s.waitContainer(c, options.Attach)
}()
}
return nil
}
func (s *composeService) waitContainer(ctx context.Context, c moby.Container, listener compose.ContainerEventListener) {
statusC, errC := s.apiClient.ContainerWait(ctx, c.ID, container.WaitConditionNotRunning)
func (s *composeService) waitContainer(c moby.Container, listener compose.ContainerEventListener) {
statusC, errC := s.apiClient.ContainerWait(context.Background(), c.ID, container.WaitConditionNotRunning)
name := getContainerNameWithoutProject(c)
select {
case status := <-statusC: