MCPcopy Index your code
hub / github.com/docker/cli / newSaveCommand

Function newSaveCommand

cli/command/image/save.go:26–52  ·  view source on GitHub ↗

newSaveCommand creates a new "docker image save" command.

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

24
25// newSaveCommand creates a new "docker image save" command.
26func newSaveCommand(dockerCLI command.Cli) *cobra.Command {
27 var opts saveOptions
28
29 cmd := &cobra.Command{
30 Use: "save [OPTIONS] IMAGE [IMAGE...]",
31 Short: "Save one or more images to a tar archive (streamed to STDOUT by default)",
32 Args: cli.RequiresMinArgs(1),
33 RunE: func(cmd *cobra.Command, args []string) error {
34 opts.images = args
35 return runSave(cmd.Context(), dockerCLI, opts)
36 },
37 Annotations: map[string]string{
38 "aliases": "docker image save, docker save",
39 },
40 ValidArgsFunction: completion.ImageNames(dockerCLI, -1),
41 DisableFlagsInUseLine: true,
42 }
43
44 flags := cmd.Flags()
45
46 flags.StringVarP(&opts.output, "output", "o", "", "Write to a file, instead of STDOUT")
47 flags.StringSliceVar(&opts.platform, "platform", []string{}, `Save only the given platform(s). Formatted as a comma-separated list of "os[/arch[/variant]]" (e.g., "linux/amd64,linux/arm64/v8")`)
48 _ = flags.SetAnnotation("platform", "version", []string{"1.48"})
49
50 _ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms())
51 return cmd
52}
53
54// runSave performs a save against the engine based on the specified options
55func runSave(ctx context.Context, dockerCLI command.Cli, opts saveOptions) error {

Callers 3

newImageCommandFunction · 0.85
TestNewSaveCommandErrorsFunction · 0.85

Calls 1

runSaveFunction · 0.85

Tested by 2

TestNewSaveCommandErrorsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…