diff --git a/cmd/compose/pull.go b/cmd/compose/pull.go index 5b0af8e12dc..7398d510a51 100644 --- a/cmd/compose/pull.go +++ b/cmd/compose/pull.go @@ -38,6 +38,7 @@ type pullOptions struct { includeDeps bool ignorePullFailures bool noBuildable bool + missing bool } func pullCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command { @@ -67,6 +68,7 @@ func pullCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) flags.MarkHidden("no-parallel") //nolint:errcheck cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures.") cmd.Flags().BoolVar(&opts.noBuildable, "ignore-buildable", false, "Ignore images that can be built.") + cmd.Flags().BoolVar(&opts.missing, "missing", false, "Only pull images that are not present in local cache.") return cmd } @@ -83,6 +85,13 @@ func runPull(ctx context.Context, dockerCli command.Cli, backend api.Service, op } } + if opts.missing { + for i, service := range project.Services { + service.PullPolicy = types.PullPolicyMissing + project.Services[i] = service + } + } + return backend.Pull(ctx, project, api.PullOptions{ Quiet: opts.quiet, IgnoreFailures: opts.ignorePullFailures,