{"record":{"id":"1343fbce53aecbc5","repo":"docker/cli","slug":"error-while-copy-s-w","errorCode":null,"errorMessage":"error while Copy (%s): %w","messagePattern":"error while Copy \\((.+?)\\): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/system/dial_stdio.go","lineNumber":85,"sourceCode":"\t\terr = <-conn2stdout\n\tcase err = <-conn2stdout:\n\t\t// return immediately without waiting for stdin to be closed.\n\t\t// (stdin is never closed when tty)\n\t}\n\treturn err\n}\n\nfunc copier(to halfWriteCloser, from halfReadCloser, debugDescription string) error {\n\tdefer func() {\n\t\tif err := from.CloseRead(); err != nil {\n\t\t\tlogrus.Errorf(\"error while CloseRead (%s): %v\", debugDescription, err)\n\t\t}\n\t\tif err := to.CloseWrite(); err != nil {\n\t\t\tlogrus.Errorf(\"error while CloseWrite (%s): %v\", debugDescription, err)\n\t\t}\n\t}()\n\tif _, err := io.Copy(to, from); err != nil {\n\t\treturn fmt.Errorf(\"error while Copy (%s): %w\", debugDescription, err)\n\t}\n\treturn nil\n}\n\ntype halfReadCloser interface {\n\tio.Reader\n\tCloseRead() error\n}\n\ntype halfWriteCloser interface {\n\tio.Writer\n\tCloseWrite() error\n}\n\ntype halfCloser interface {\n\thalfReadCloser\n\thalfWriteCloser\n}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/system/dial_stdio.go#L67-L103","documentation":"Wrapped I/O error from io.Copy while shuttling bytes between stdio and the daemon raw stream connection in 'docker system dial-stdio'. The debugDescription distinguishes the 'stdin to stream' vs 'stream to stdout' direction.","triggerScenarios":"Either half of the bidirectional copy fails: the daemon closes the stream mid-transfer, the peer resets the connection, stdin/stdout hits an error, or the underlying connection breaks. Returned by copier at dial_stdio.go:84-86.","commonSituations":"Daemon restart during a proxied operation; peer disconnect; broken pipe on stdout (e.g. piping to a closed process); network interruption over a tcp daemon endpoint.","solutions":["Re-establish the operation once the daemon is stable ('docker version').","Ensure the downstream consumer of stdout is alive for the whole transfer.","For tcp endpoints, confirm network stability / reduce MTU issues."],"exampleFix":"// before: copy fails mid-transfer due to daemon reset\ndocker system dial-stdio\n\n// after: stabilize daemon then retry\nsystemctl restart docker\nsleep 2\ndocker version && docker system dial-stdio","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isCopyErr(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"error while Copy\")\n}","tryCatchPattern":"if _, err := io.Copy(to, from); err != nil {\n    if errors.Is(err, io.EOF) || isClosedConn(err) {\n        // peer closed cleanly\n        return nil\n    }\n    return fmt.Errorf(\"error while Copy (%s): %w\", dir, err)\n}","preventionTips":["Treat clean peer-close as EOF, not error, where appropriate.","Keep the daemon stable across the proxied operation.","Ensure the stdout consumer stays alive for the full transfer."],"tags":["system","dial-stdio","io","network"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}