Skip to content

Commit

Permalink
fix: return correct exit code with --exit-code-from (#11715)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeloof committed Apr 16, 2024
1 parent b3792dd commit c9e070f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/compose/printer.go
Expand Up @@ -138,9 +138,11 @@ func (p *printer) Run(cascade api.Cascade, exitCodeFrom string, stopFn func() er
if cascade == api.CascadeStop && exitCodeFrom == "" {
exitCodeFrom = event.Service
}
if exitCodeFrom == event.Service {
exitCode = event.ExitCode
}
}

if exitCodeFrom == event.Service && (event.Type == api.ContainerEventExit || event.Type == api.ContainerEventStopped) {
// Container was interrupted or exited, let's capture exit code
exitCode = event.ExitCode
}
if len(containers) == 0 {
// Last container terminated, done
Expand Down
1 change: 1 addition & 0 deletions pkg/compose/start.go
Expand Up @@ -268,6 +268,7 @@ func (s *composeService) watchContainers(ctx context.Context, //nolint:gocyclo
Container: name,
ID: container.ID,
Service: service,
ExitCode: inspected.State.ExitCode,
})
}

Expand Down

0 comments on commit c9e070f

Please sign in to comment.