Skip to content

Commit

Permalink
Merge pull request docker#10828 from thaJeztah/minor_cli_changes
Browse files Browse the repository at this point in the history
pkg/compose: RunOneOffContainer: don't use NewStartOptions()
  • Loading branch information
glours authored Jul 19, 2023
2 parents 150b88a + 4eb43c5 commit 9174a99
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions pkg/compose/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package compose

import (
"context"
"errors"
"fmt"
"os"
"os/signal"
Expand All @@ -36,11 +37,6 @@ func (s *composeService) RunOneOffContainer(ctx context.Context, project *types.
return 0, err
}

start := cmd.NewStartOptions()
start.OpenStdin = !opts.Detach && opts.Interactive
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()

Expand All @@ -49,9 +45,14 @@ func (s *composeService) RunOneOffContainer(ctx context.Context, project *types.
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
err = cmd.RunStart(s.dockerCli, &cmd.StartOptions{
OpenStdin: !opts.Detach && opts.Interactive,
Attach: !opts.Detach,
Containers: []string{containerID},
})
var stErr cli.StatusError
if errors.As(err, &stErr) {
return stErr.StatusCode, nil
}
return 0, err
}
Expand Down

0 comments on commit 9174a99

Please sign in to comment.