@@ -31,6 +31,7 @@ import (
3131 "github.com/compose-spec/compose-go/v2/types"
3232 "github.com/docker/cli/cli/command"
3333 "github.com/docker/cli/opts"
34+ ui "github.com/docker/compose/v2/pkg/progress"
3435 "github.com/mattn/go-shellwords"
3536 "github.com/spf13/cobra"
3637 "github.com/spf13/pflag"
@@ -67,6 +68,8 @@ type runOptions struct {
6768 noDeps bool
6869 ignoreOrphans bool
6970 removeOrphans bool
71+ quiet bool
72+ quietBuild bool
7073 quietPull bool
7174}
7275
@@ -180,6 +183,14 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
180183 options .noTty = ! options .tty
181184 }
182185 }
186+ if options .quiet {
187+ ui .Mode = ui .ModeQuiet
188+ devnull , err := os .Open (os .DevNull )
189+ if err != nil {
190+ return err
191+ }
192+ os .Stdout = devnull
193+ }
183194 createOpts .pullChanged = cmd .Flags ().Changed ("pull" )
184195 return nil
185196 }),
@@ -222,6 +233,8 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
222233 flags .BoolVar (& options .useAliases , "use-aliases" , false , "Use the service's network useAliases in the network(s) the container connects to" )
223234 flags .BoolVarP (& options .servicePorts , "service-ports" , "P" , false , "Run command with all service's ports enabled and mapped to the host" )
224235 flags .StringVar (& createOpts .Pull , "pull" , "policy" , `Pull image before running ("always"|"missing"|"never")` )
236+ flags .BoolVarP (& options .quiet , "quiet" , "q" , false , "Don't print anything to STDOUT" )
237+ flags .BoolVar (& buildOpts .quiet , "quiet-build" , false , "Suppress progress output from the build process" )
225238 flags .BoolVar (& options .quietPull , "quiet-pull" , false , "Pull without printing progress information" )
226239 flags .BoolVar (& createOpts .Build , "build" , false , "Build image before starting container" )
227240 flags .BoolVar (& options .removeOrphans , "remove-orphans" , false , "Remove containers for services not defined in the Compose file" )
0 commit comments