newPullCommand creates a new `docker pull` command
(dockerCLI command.Cli)
| 29 | |
| 30 | // newPullCommand creates a new `docker pull` command |
| 31 | func newPullCommand(dockerCLI command.Cli) *cobra.Command { |
| 32 | var opts pullOptions |
| 33 | |
| 34 | cmd := &cobra.Command{ |
| 35 | Use: "pull [OPTIONS] NAME[:TAG|@DIGEST]", |
| 36 | Short: "Download an image from a registry", |
| 37 | Args: cli.ExactArgs(1), |
| 38 | RunE: func(cmd *cobra.Command, args []string) error { |
| 39 | opts.remote = args[0] |
| 40 | return runPull(cmd.Context(), dockerCLI, opts) |
| 41 | }, |
| 42 | Annotations: map[string]string{ |
| 43 | "category-top": "5", |
| 44 | "aliases": "docker image pull, docker pull", |
| 45 | }, |
| 46 | // Complete with local images to help pulling the latest version |
| 47 | // of images that are in the image cache. |
| 48 | ValidArgsFunction: completion.ImageNames(dockerCLI, 1), |
| 49 | DisableFlagsInUseLine: true, |
| 50 | } |
| 51 | |
| 52 | flags := cmd.Flags() |
| 53 | |
| 54 | flags.BoolVarP(&opts.all, "all-tags", "a", false, "Download all tagged images in the repository") |
| 55 | flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output") |
| 56 | |
| 57 | // TODO(thaJeztah): DEPRECATED: remove in v29.1 or v30 |
| 58 | flags.Bool("disable-content-trust", true, "Skip image verification (deprecated)") |
| 59 | _ = flags.MarkDeprecated("disable-content-trust", "support for docker content trust was removed") |
| 60 | |
| 61 | flags.StringVar(&opts.platform, "platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), "Set platform if server is multi-platform capable") |
| 62 | _ = flags.SetAnnotation("platform", "version", []string{"1.32"}) |
| 63 | _ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms()) |
| 64 | |
| 65 | return cmd |
| 66 | } |
| 67 | |
| 68 | // runPull performs a pull against the engine based on the specified options |
| 69 | func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error { |
searching dependent graphs…