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

Function runExport

cli/command/container/export.go:48–72  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, opts exportOptions)

Source from the content-addressed store, hash-verified

46}
47
48func runExport(ctx context.Context, dockerCLI command.Cli, opts exportOptions) error {
49 var output io.Writer
50 if opts.output == "" {
51 if dockerCLI.Out().IsTerminal() {
52 return errors.New("cowardly refusing to save to a terminal. Use the -o flag or redirect")
53 }
54 output = dockerCLI.Out()
55 } else {
56 writer, err := atomicwriter.New(opts.output, 0o600)
57 if err != nil {
58 return fmt.Errorf("failed to export container: %w", err)
59 }
60 defer writer.Close()
61 output = writer
62 }
63
64 responseBody, err := dockerCLI.Client().ContainerExport(ctx, opts.container, client.ContainerExportOptions{})
65 if err != nil {
66 return err
67 }
68 defer responseBody.Close()
69
70 _, err = io.Copy(output, responseBody)
71 return err
72}

Callers 1

newExportCommandFunction · 0.70

Calls 5

ContainerExportMethod · 0.80
OutMethod · 0.65
ClientMethod · 0.65
IsTerminalMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…