1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

docs: Updated for docker cp and its API changes

Documented changes to API to enable new `docker cp` behavior.

Added documentation on `docker cp` usage and behavior.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
This commit is contained in:
Josh Hawn 2015-05-15 11:35:41 -07:00
parent 418135e7ea
commit e54b1e081a
4 changed files with 324 additions and 41 deletions

View file

@ -68,6 +68,23 @@ Running `docker rmi` emits an **untag** event when removing an image name. The
### What's new
`GET /containers/(id)/archive`
**New!**
Get an archive of filesystem content from a container.
`PUT /containers/(id)/archive`
**New!**
Upload an archive of content to be extracted to an
existing directory inside a container's filesystem.
`POST /containers/(id)/copy`
**Deprecated!**
This copy endpoint has been deprecated in favor of the above `archive` endpoint
which can be used to download files and directories from a container.
**New!**
The `hostConfig` option now accepts the field `GroupAdd`, which specifies a list of additional
groups that the container process will run as.

View file

@ -1039,6 +1039,8 @@ Status Codes:
Copy files or folders of container `id`
**Deprecated** in favor of the `archive` endpoint below.
**Example request**:
POST /containers/4fa6e0f0c678/copy HTTP/1.1
@ -1061,6 +1063,120 @@ Status Codes:
- **404** no such container
- **500** server error
### Retrieving information about files and folders in a container
`HEAD /containers/(id)/archive`
See the description of the `X-Docker-Container-Path-Stat` header in the
folowing section.
### Get an archive of a filesystem resource in a container
`GET /containers/(id)/archive`
Get an tar archive of a resource in the filesystem of container `id`.
Query Parameters:
- **path** - resource in the container's filesystem to archive. Required.
If not an absolute path, it is relative to the container's root directory.
The resource specified by **path** must exist. To assert that the resource
is expected to be a directory, **path** should end in `/` or `/.`
(assuming a path separator of `/`). If **path** ends in `/.` then this
indicates that only the contents of the **path** directory should be
copied. A symlink is always resolved to its target.
**Note**: It is not possible to copy certain system files such as resources
under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
container.
**Example request**:
GET /containers/8cce319429b2/archive?path=/root HTTP/1.1
**Example response**:
HTTP/1.1 200 OK
Content-Type: application/x-tar
X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInBhdGgiOiIvcm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oifQ==
{{ TAR STREAM }}
On success, a response header `X-Docker-Container-Path-Stat` will be set to a
base64-encoded JSON object containing some filesystem header information about
the archived resource. The above example value would decode to the following
JSON object (whitespace added for readability):
{
"name": "root",
"path": "/root",
"size": 4096,
"mode": 2147484096,
"mtime": "2014-02-27T20:51:23Z"
}
A `HEAD` request can also be made to this endpoint if only this information is
desired.
Status Codes:
- **200** - success, returns archive of copied resource
- **400** - client error, bad parameter, details in JSON response body, one of:
- must specify path parameter (**path** cannot be empty)
- not a directory (**path** was asserted to be a directory but exists as a
file)
- **404** - client error, resource not found, one of:
no such container (container `id` does not exist)
- no such file or directory (**path** does not exist)
- **500** - server error
### Extract an archive of files or folders to a directory in a container
`PUT /containers/(id)/archive`
Upload a tar archive to be extracted to a path in the filesystem of container
`id`.
Query Parameters:
- **path** - path to a directory in the container
to extract the archive's contents into. Required.
If not an absolute path, it is relative to the container's root directory.
The **path** resource must exist.
- **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error
if unpacking the given content would cause an existing directory to be
replaced with a non-directory and vice versa.
**Example request**:
PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
Content-Type: application/x-tar
{{ TAR STREAM }}
**Example response**:
HTTP/1.1 200 OK
Status Codes:
- **200** the content was extracted successfully
- **400** - client error, bad parameter, details in JSON response body, one of:
- must specify path parameter (**path** cannot be empty)
- not a directory (**path** should be a directory but exists as a file)
- unable to overwrite existing directory with non-directory
(if **noOverwriteDirNonDir**)
- unable to overwrite existing non-directory with directory
(if **noOverwriteDirNonDir**)
- **403** - client error, permission denied, the volume
or container rootfs is marked as read-only.
- **404** - client error, resource not found, one of:
no such container (container `id` does not exist)
- no such file or directory (**path** resource does not exist)
- **500** server error
## 2.2 Images
### List Images