{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/9871","labels_url":"https://api.github.com/repos/docker/docker/issues/9871/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/9871/comments","events_url":"https://api.github.com/repos/docker/docker/issues/9871/events","html_url":"https://github.com/docker/docker/pull/9871","id":53246810,"number":9871,"title":"docker cp to, from, and between containers","user":{"login":"jlhawn","id":1441929,"avatar_url":"https://avatars.githubusercontent.com/u/1441929?v=3","gravatar_id":"","url":"https://api.github.com/users/jlhawn","html_url":"https://github.com/jlhawn","followers_url":"https://api.github.com/users/jlhawn/followers","following_url":"https://api.github.com/users/jlhawn/following{/other_user}","gists_url":"https://api.github.com/users/jlhawn/gists{/gist_id}","starred_url":"https://api.github.com/users/jlhawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlhawn/subscriptions","organizations_url":"https://api.github.com/users/jlhawn/orgs","repos_url":"https://api.github.com/users/jlhawn/repos","events_url":"https://api.github.com/users/jlhawn/events{/privacy}","received_events_url":"https://api.github.com/users/jlhawn/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/%2Fproject%2Fdoc","name":"/project/doc","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":18,"created_at":"2015-01-02T10:50:20Z","updated_at":"2015-01-05T17:23:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/9871","html_url":"https://github.com/docker/docker/pull/9871","diff_url":"https://github.com/docker/docker/pull/9871.diff","patch_url":"https://github.com/docker/docker/pull/9871.patch"},"body":"# Improve `docker cp`\r\n\r\nThis command currently uses the following HTTP API endpoint:\r\n\r\n\tPOST /containers/(id)/copy\r\n\r\nThis endpoint only supports copying files/directories from a container to the\r\nclient. Its behavior is also odd in that `DEST` is always treated as a\r\ndirectory. It would be preferrable to have the same behavior as standard Unix\r\nutilities like `cp` and `scp`.\r\n\r\n## New API Endpoints\r\n\r\nThis endpoint may be split into two separate API endpoints to handle copying\r\nfiles or directories to and from a container:\r\n\r\n\tGET /containers/(id)/copy?path=/container/path\r\n\r\nThis endpoint has similar behavior to the current `copy` endpoint and is used\r\nto copy data from the container to the client. The difference is that it will\r\ncorrectly handle the case when the source is a file or is a directory and ends\r\nwith a trailing path separator, including the directory or only its contents.\r\n\r\n\tPUT /containers/(id)/copy?srcPath=/local/path&dstPath=/container/path\r\n\r\nThis endpoint may be used for copying data from the client to a destination\r\npath inside a container.\r\n\r\nUse of these 2 endpoints together would allow for a client to copy files or\r\ndirectories from one container to another, but this would require transfering\r\nan archive through the client. For this purpose, a 3rd endpoint can be used:\r\n\r\n\tPUT /containers/(id)/copy-across?dstContainer=id&srcPath=/path1&dstPath=/path2\r\n\r\nAny container paths which are not absolute are considered relative to the\r\ncontainer's working directory.\r\n\r\n## CLI Usage\r\n\r\n### copy from a container to the client\r\n\r\n\tdocker cp CONTAINER:PATH LOCALPATH\r\n\r\nCopies a file or directory at PATH in the specified `CONTAINER` to a\r\n`LOCALPATH` on the client.\r\n\r\n### copy from the client to a container\r\n\r\n    docker cp LOCALPATH CONTAINER:PATH\r\n\r\nCopies a file or directory at `LOCALPATH` to `PATH` in the specified\r\n`CONTAINER`.\r\n\r\n### copy from one container to another\r\n\r\n    docker cp SRC_CONTAINER:SRC_PATH DST_CONTAINER:DST_PATH\r\n\r\nCopies a file or directory at `SRC_PATH` in `SRC_CONTAINER` to `DST_PATH` in\r\nthe `DST_CONTAINER`.\r\n\r\n## Behavior of `docker cp SOURCE DEST`\r\n\r\nThe behavior has been changed to be similar to a combination of `mkdir -p` and\r\n`cp -r`:\r\n\r\n- `SOURCE` specifies a file\r\n    - `DEST` does not exist\r\n        - the file is saved to a file created at `DEST`\r\n    - `DEST` exists and is a file\r\n        - the file is overwritten with the contents of the source file\r\n    - `DEST` exists and is a directory\r\n        - the file is saved to this directory using the basename from `PATH`\r\n- `SOURCE` specifies a directory (no trailing path separator)\r\n    - `DEST` does not exist\r\n        - `DEST` is created as a directory and the source directory is copied\r\n          into this directory\r\n    - `DEST` exists and is a file\r\n        - Error condition: cannot copy a directory to a file\r\n    - `DEST` exists and is a directory\r\n        - the source directory is copied into this directory\r\n- `SOURCE` specifies a directory (with trailing path separator)\r\n    - `DEST` does not exist\r\n        - `DEST` is created as a directory and the source directory's contents\r\n          are copied into this directory\r\n    - `DEST` exists and is a file\r\n        - Error condition: cannot copy a directory to a file\r\n    - `DEST` exists and is a directory\r\n        - the source directory's contents are copied into this directory\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/68741935","html_url":"https://github.com/docker/docker/pull/9871#issuecomment-68741935","issue_url":"https://api.github.com/repos/docker/docker/issues/9871","id":68741935,"user":{"login":"jfrazelle","id":1445228,"avatar_url":"https://avatars.githubusercontent.com/u/1445228?v=3","gravatar_id":"","url":"https://api.github.com/users/jfrazelle","html_url":"https://github.com/jfrazelle","followers_url":"https://api.github.com/users/jfrazelle/followers","following_url":"https://api.github.com/users/jfrazelle/following{/other_user}","gists_url":"https://api.github.com/users/jfrazelle/gists{/gist_id}","starred_url":"https://api.github.com/users/jfrazelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfrazelle/subscriptions","organizations_url":"https://api.github.com/users/jfrazelle/orgs","repos_url":"https://api.github.com/users/jfrazelle/repos","events_url":"https://api.github.com/users/jfrazelle/events{/privacy}","received_events_url":"https://api.github.com/users/jfrazelle/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T17:23:07Z","updated_at":"2015-01-05T17:23:07Z","body":"I think the docs could be added on this PR seeing as its not really a proposal but a bug fix"}}