{"id":"68ea226946a8a497","repo":"docker/cli","slug":"failed-to-export-container-w","errorCode":null,"errorMessage":"failed to export container: %w","messagePattern":"failed to export container: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/export.go","lineNumber":58,"sourceCode":"\n\tflags := cmd.Flags()\n\n\tflags.StringVarP(&opts.output, \"output\", \"o\", \"\", \"Write to a file, instead of STDOUT\")\n\n\treturn cmd\n}\n\nfunc runExport(ctx context.Context, dockerCLI command.Cli, opts exportOptions) error {\n\tvar output io.Writer\n\tif opts.output == \"\" {\n\t\tif dockerCLI.Out().IsTerminal() {\n\t\t\treturn errors.New(\"cowardly refusing to save to a terminal. Use the -o flag or redirect\")\n\t\t}\n\t\toutput = dockerCLI.Out()\n\t} else {\n\t\twriter, err := atomicwriter.New(opts.output, 0o600)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to export container: %w\", err)\n\t\t}\n\t\tdefer writer.Close()\n\t\toutput = writer\n\t}\n\n\tresponseBody, err := dockerCLI.Client().ContainerExport(ctx, opts.container, client.ContainerExportOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer responseBody.Close()\n\n\t_, err = io.Copy(output, responseBody)\n\treturn err\n}\n","sourceCodeStart":40,"sourceCodeEnd":73,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/export.go#L40-L73","documentation":"Error \"failed to export container: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/container/export.go:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}