diff --git a/pkg/compose/run.go b/pkg/compose/run.go index d0ae1b9ab..36fedbfaf 100644 --- a/pkg/compose/run.go +++ b/pkg/compose/run.go @@ -19,6 +19,8 @@ package compose import ( "context" "fmt" + "os" + "os/signal" "github.com/compose-spec/compose-go/types" "github.com/docker/cli/cli" @@ -38,6 +40,14 @@ func (s *composeService) RunOneOffContainer(ctx context.Context, project *types. start.Attach = !opts.Detach start.Containers = []string{containerID} + // remove cancellable context signal handler so we can forward signals to container without compose to exit + signal.Reset() + + sigc := make(chan os.Signal, 128) + signal.Notify(sigc) + go cmd.ForwardAllSignals(ctx, s.dockerCli, containerID, sigc) + defer signal.Stop(sigc) + err = cmd.RunStart(s.dockerCli, &start) if sterr, ok := err.(cli.StatusError); ok { return sterr.StatusCode, nil