newExportCommand creates a new "docker container export" command.
(dockerCLI command.Cli)
| 21 | |
| 22 | // newExportCommand creates a new "docker container export" command. |
| 23 | func newExportCommand(dockerCLI command.Cli) *cobra.Command { |
| 24 | var opts exportOptions |
| 25 | |
| 26 | cmd := &cobra.Command{ |
| 27 | Use: "export [OPTIONS] CONTAINER", |
| 28 | Short: "Export a container's filesystem as a tar archive", |
| 29 | Args: cli.ExactArgs(1), |
| 30 | RunE: func(cmd *cobra.Command, args []string) error { |
| 31 | opts.container = args[0] |
| 32 | return runExport(cmd.Context(), dockerCLI, opts) |
| 33 | }, |
| 34 | Annotations: map[string]string{ |
| 35 | "aliases": "docker container export, docker export", |
| 36 | }, |
| 37 | ValidArgsFunction: completion.ContainerNames(dockerCLI, true), |
| 38 | DisableFlagsInUseLine: true, |
| 39 | } |
| 40 | |
| 41 | flags := cmd.Flags() |
| 42 | |
| 43 | flags.StringVarP(&opts.output, "output", "o", "", "Write to a file, instead of STDOUT") |
| 44 | |
| 45 | return cmd |
| 46 | } |
| 47 | |
| 48 | func runExport(ctx context.Context, dockerCLI command.Cli, opts exportOptions) error { |
| 49 | var output io.Writer |
searching dependent graphs…