{"record":{"id":"e0f643d5dae7264e","repo":"zed-industries/zed","slug":"failed-to-upload-via-docker-cp","errorCode":null,"errorMessage":"failed to upload via docker cp {} -> {}: {}","messagePattern":"failed to upload via docker cp (.+?) -> (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/remote/src/transport/docker.rs","lineNumber":451,"sourceCode":"\n    async fn upload_and_chown(\n        docker_cli: String,\n        connection_options: DockerConnectionOptions,\n        src_path: String,\n        dst_path: String,\n    ) -> Result<()> {\n        let mut command = util::command::new_command(&docker_cli);\n        command.kill_on_drop(true);\n        command.arg(\"cp\");\n        command.arg(\"-a\");\n        command.arg(&src_path);\n        command.arg(format!(\"{}:{}\", connection_options.container_id, dst_path));\n\n        let output = command.output().await?;\n\n        if !output.status.success() {\n            let stderr = String::from_utf8_lossy(&output.stderr);\n            log::debug!(\"failed to upload via docker cp {src_path} -> {dst_path}: {stderr}\",);\n            anyhow::bail!(\n                \"failed to upload via docker cp {} -> {}: {}\",\n                src_path,\n                dst_path,\n                stderr,\n            );\n        }\n\n        let mut chown_command = util::command::new_command(&docker_cli);\n        chown_command.kill_on_drop(true);\n        chown_command.arg(\"exec\");\n        chown_command.arg(connection_options.container_id);\n        chown_command.arg(\"chown\");\n        chown_command.arg(format!(\n            \"{}:{}\",\n            connection_options.remote_user, connection_options.remote_user,\n        ));\n        chown_command.arg(&dst_path);","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/remote/src/transport/docker.rs#L433-L469","documentation":"The Docker transport uploads the zed-remote-server binary into the container via `docker cp -a <src> <container_id>:<dst>`; this error is raised when that docker cp invocation exits non-zero and embeds the CLI's stderr. It is a failure of the docker CLI copy operation itself, not of Zed's upload logic.","triggerScenarios":"DockerExecConnection::upload_file executes docker cp against connection_options.container_id and the command fails: container not running, stale/wrong container id, destination directory missing or read-only, disk full, or docker daemon errors.","commonSituations":"Container exited or was recreated between connect and upload; destination parent directory never created in a minimal image; read-only root filesystem; rootless docker permission problems; no space left on the docker storage driver.","solutions":["Confirm the container is still running and the id resolves: `docker ps`, then reconnect so Zed re-resolves the connection","Reproduce manually with the exact paths from the message: `docker cp -a <src> <container>:<dst>` and read the embedded stderr","Ensure the destination directory exists and is writable inside the container (`docker exec <id> mkdir -p <dst_dir>`)","Check docker storage health (`docker system df`, daemon logs) if the daemon reports ENOSPC or internal errors"],"exampleFix":"# before: destination dir absent in image, docker cp fails\nFROM scratch\nCOPY app /app\n\n# after\nFROM alpine\nRUN mkdir -p /root/.local/share/zed\nCOPY app /app","handlingStrategy":"retry","validationCode":"fn container_running(output: &str, container_id: &str) -> bool {\n    output.lines().any(|l| l.trim().starts_with(container_id))\n}\n// run: docker ps --no-trunc --filter id=<container_id>","typeGuard":null,"tryCatchPattern":"let mut attempt = 0;\nloop {\n    match connection.upload_file(src, dest, dir).await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"docker cp\") && attempt < 2 => {\n            attempt += 1;\n            wait_for_container(container_id).await; // verify running before retry\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Pin the connection to a container that cannot exit mid-session (restart policy, keepalive process)","Ensure the destination directory exists and is writable before uploading","Retry docker cp once after confirming `docker ps` still lists the container"],"tags":["docker","container","file-transfer","docker-cp"],"backgroundTag":"docker-cp-failed","analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}