Skip to content

Commit 09533ef

Browse files
committed
Add the --no-build option to run
`docker compose up` supports `--no-build` but `run` doesn't expose it, even though it has the `--build` option. Fix that omission.
1 parent 4f419e5 commit 09533ef

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

cmd/compose/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *Backen
190190
// we don't have an actual terminal to attach to for interactive mode
191191
options.noTty = true
192192
}
193+
if createOpts.Build && createOpts.noBuild {
194+
return fmt.Errorf("--build and --no-build are incompatible")
195+
}
193196

194197
if options.quiet {
195198
display.Mode = display.ModeQuiet
@@ -246,6 +249,7 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *Backen
246249
flags.BoolVar(&buildOpts.quiet, "quiet-build", false, "Suppress progress output from the build process")
247250
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
248251
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
252+
flags.BoolVar(&createOpts.noBuild, "no-build", false, "Don't build an image, even if it's policy")
249253
flags.BoolVar(&options.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
250254

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

0 commit comments

Comments
 (0)