diff --git a/cmd/compose/create.go b/cmd/compose/create.go index fbbeed7008..bf21ee7afc 100644 --- a/cmd/compose/create.go +++ b/cmd/compose/create.go @@ -75,6 +75,7 @@ func createCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers") flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's policy") flags.StringVar(&opts.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never"|"build")`) + flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information") flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed") flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.") flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file") @@ -105,7 +106,7 @@ func runCreate(ctx context.Context, _ command.Cli, backend api.Service, createOp RecreateDependencies: createOpts.dependenciesRecreateStrategy(), Inherit: !createOpts.noInherit, Timeout: createOpts.GetTimeout(), - QuietPull: false, + QuietPull: createOpts.quietPull, }) } diff --git a/cmd/compose/run.go b/cmd/compose/run.go index 1803268523..b4a5da365f 100644 --- a/cmd/compose/run.go +++ b/cmd/compose/run.go @@ -231,7 +231,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op } buildForDeps = &bo } - return startDependencies(ctx, backend, *project, buildForDeps, options.Service, options.ignoreOrphans) + return startDependencies(ctx, backend, *project, buildForDeps, options) }, dockerCli.Err()) if err != nil { return err @@ -298,11 +298,11 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op return err } -func startDependencies(ctx context.Context, backend api.Service, project types.Project, buildOpts *api.BuildOptions, requestedServiceName string, ignoreOrphans bool) error { +func startDependencies(ctx context.Context, backend api.Service, project types.Project, buildOpts *api.BuildOptions, options runOptions) error { dependencies := types.Services{} var requestedService types.ServiceConfig for name, service := range project.Services { - if name != requestedServiceName { + if name != options.Service { dependencies[name] = service } else { requestedService = service @@ -310,10 +310,11 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P } project.Services = dependencies - project.DisabledServices[requestedServiceName] = requestedService + project.DisabledServices[options.Service] = requestedService err := backend.Create(ctx, &project, api.CreateOptions{ Build: buildOpts, - IgnoreOrphans: ignoreOrphans, + IgnoreOrphans: options.ignoreOrphans, + QuietPull: options.quietPull, }) if err != nil { return err diff --git a/docs/reference/compose_create.md b/docs/reference/compose_create.md index 386d6359ac..06293625a1 100644 --- a/docs/reference/compose_create.md +++ b/docs/reference/compose_create.md @@ -13,6 +13,7 @@ Creates containers for a service | `--no-build` | | | Don't build an image, even if it's policy | | `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. | | `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never"\|"build") | +| `--quiet-pull` | | | Pull without printing progress information | | `--remove-orphans` | | | Remove containers for services not defined in the Compose file | | `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. | diff --git a/docs/reference/docker_compose_create.yaml b/docs/reference/docker_compose_create.yaml index 34425aebb8..a07e1c88cc 100644 --- a/docs/reference/docker_compose_create.yaml +++ b/docs/reference/docker_compose_create.yaml @@ -57,6 +57,16 @@ options: experimentalcli: false kubernetes: false swarm: false + - option: quiet-pull + value_type: bool + default_value: "false" + description: Pull without printing progress information + deprecated: false + hidden: false + experimental: false + experimentalcli: false + kubernetes: false + swarm: false - option: remove-orphans value_type: bool default_value: "false" diff --git a/pkg/e2e/compose_run_test.go b/pkg/e2e/compose_run_test.go index b074e6a80e..e552e4653d 100644 --- a/pkg/e2e/compose_run_test.go +++ b/pkg/e2e/compose_run_test.go @@ -160,4 +160,13 @@ func TestLocalComposeRun(t *testing.T) { c.RunDockerComposeCmd(t, "-f", "./fixtures/dependencies/deps-not-required.yaml", "down", "--remove-orphans") }) + + t.Run("--quiet-pull", func(t *testing.T) { + res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/compose.yaml", "down", "--rmi", "all") + res.Assert(t, icmd.Success) + + res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/compose.yaml", "run", "--quiet-pull", "back") + assert.Assert(t, !strings.Contains(res.Combined(), "Pull complete"), res.Combined()) + assert.Assert(t, strings.Contains(res.Combined(), "Pulled"), res.Combined()) + }) }