Skip to content

Commit

Permalink
run: add support --no-build, --pull flags
Browse files Browse the repository at this point in the history
Allows setting build- and pull policies for `compose run` like for `docker run` and `compose up`.

Signed-off-by: legobt <[email protected]>
  • Loading branch information
legobeat committed Aug 2, 2024
1 parent ea4ccf6 commit 95e5968
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/compose/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
options.noTty = !options.tty
}
}
if cmd.Flags().Changed("build") {
if cmd.Flags().Changed("no-build") {
return fmt.Errorf("--build and --no-build are incompatible")
} else {
options.noTty = !options.tty
}
}
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
Expand Down Expand Up @@ -189,6 +196,8 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host")
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
flags.BoolVar(&createOpts.noBuild, "no-build", false, "Don't build an image, even if it's policy")
flags.StringVar(&createOpts.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
flags.BoolVar(&createOpts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")

cmd.Flags().BoolVarP(&options.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
Expand Down

0 comments on commit 95e5968

Please sign in to comment.