mirror of https://github.com/docker/docs.git
Merge pull request #13562 from moxiegirl/fixes-to-119-api
Fixes to the 1.19 version Thank you @thaJeztah and @jfrazelle!
This commit is contained in:
commit
742a8a6cff
|
@ -10,11 +10,11 @@ page_keywords: API, Docker, rcli, REST, documentation
|
||||||
- The daemon listens on `unix:///var/run/docker.sock` but you can
|
- The daemon listens on `unix:///var/run/docker.sock` but you can
|
||||||
[Bind Docker to another host/port or a Unix socket](
|
[Bind Docker to another host/port or a Unix socket](
|
||||||
/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
|
/articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
|
||||||
- The API tends to be REST, but for some complex commands, like `attach`
|
- The API tends to be REST. However, for some complex commands, like `attach`
|
||||||
or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
|
or `pull`, the HTTP connection is hijacked to transport `stdout`,
|
||||||
`STDIN` and `STDERR`.
|
`stdin` and `stderr`.
|
||||||
- When the client API version is newer than the daemon's an HTTP
|
- When the client API version is newer than the daemon's, these calls return an HTTP
|
||||||
`400 Bad Request` error message is returned.
|
`400 Bad Request` error message.
|
||||||
|
|
||||||
# 2. Endpoints
|
# 2. Endpoints
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@ Query Parameters:
|
||||||
non-running ones.
|
non-running ones.
|
||||||
- **size** – 1/True/true or 0/False/false, Show the containers
|
- **size** – 1/True/true or 0/False/false, Show the containers
|
||||||
sizes
|
sizes
|
||||||
- **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
|
- **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
|
||||||
- exited=<int> -- containers with exit code of <int>
|
- `exited=<int>`; -- containers with exit code of `<int>` ;
|
||||||
- status=(restarting|running|paused|exited)
|
- `status=`(`restarting`|`running`|`paused`|`exited`)
|
||||||
- label=`key` or `key=value` of a container label
|
- `label=key` or `key=value` of a container label
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -186,54 +186,53 @@ Create a container
|
||||||
|
|
||||||
Json Parameters:
|
Json Parameters:
|
||||||
|
|
||||||
- **Hostname** - A string value containing the desired hostname to use for the
|
- **Hostname** - A string value containing the hostname to use for the
|
||||||
container.
|
container.
|
||||||
- **Domainname** - A string value containing the desired domain name to use
|
- **Domainname** - A string value containing the domain name to use
|
||||||
for the container.
|
for the container.
|
||||||
- **User** - A string value containing the user to use inside the container.
|
- **User** - A string value specifying the user inside the container.
|
||||||
- **Memory** - Memory limit in bytes.
|
- **Memory** - Memory limit in bytes.
|
||||||
- **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap,
|
- **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap
|
||||||
always use this with `memory`, and make the value larger than `memory`.
|
You must use this with `memory` and make the swap value larger than `memory`.
|
||||||
- **CpuShares** - An integer value containing the CPU Shares for container
|
- **CpuShares** - An integer value containing the container's CPU Shares
|
||||||
(ie. the relative weight vs other containers).
|
(ie. the relative weight vs other containers).
|
||||||
- **CpuPeriod** - The length of a CPU period (in microseconds).
|
- **CpuPeriod** - The length of a CPU period in microseconds.
|
||||||
- **Cpuset** - The same as CpusetCpus, but deprecated, please don't use.
|
- **Cpuset** - Deprecated please don't use. Use `CpusetCpus` instead.
|
||||||
- **CpusetCpus** - String value containing the cgroups CpusetCpus to use.
|
- **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use.
|
||||||
- **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
|
- **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
|
||||||
- **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
|
- **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
|
||||||
- **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
|
- **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
|
||||||
- **AttachStdin** - Boolean value, attaches to stdin.
|
- **AttachStdin** - Boolean value, attaches to `stdin`.
|
||||||
- **AttachStdout** - Boolean value, attaches to stdout.
|
- **AttachStdout** - Boolean value, attaches to `stdout`.
|
||||||
- **AttachStderr** - Boolean value, attaches to stderr.
|
- **AttachStderr** - Boolean value, attaches to `stderr`.
|
||||||
- **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
|
- **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
|
||||||
- **OpenStdin** - Boolean value, opens stdin,
|
- **OpenStdin** - Boolean value, opens stdin,
|
||||||
- **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects.
|
- **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects.
|
||||||
- **Env** - A list of environment variables in the form of `VAR=value`
|
- **Env** - A list of environment variables in the form of `VAR=value`
|
||||||
- **Labels** - Adds a map of labels that to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
|
- **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
|
||||||
- **Cmd** - Command to run specified as a string or an array of strings.
|
- **Cmd** - Command to run specified as a string or an array of strings.
|
||||||
- **Entrypoint** - Set the entrypoint for the container a a string or an array
|
- **Entrypoint** - Set the entry point for the container as a string or an array
|
||||||
of strings
|
of strings.
|
||||||
- **Image** - String value containing the image name to use for the container
|
- **Image** - A string specifying the image name to use for the container.
|
||||||
- **Volumes** – An object mapping mountpoint paths (strings) inside the
|
- **Volumes** – An object mapping mount point paths (strings) inside the
|
||||||
container to empty objects.
|
container to empty objects.
|
||||||
- **WorkingDir** - A string value containing the working dir for commands to
|
- **WorkingDir** - A string specifying the working directory for commands to
|
||||||
run in.
|
run in.
|
||||||
- **NetworkDisabled** - Boolean value, when true disables networking for the
|
- **NetworkDisabled** - Boolean value, when true disables networking for the
|
||||||
container
|
container
|
||||||
- **ExposedPorts** - An object mapping ports to an empty object in the form of:
|
- **ExposedPorts** - An object mapping ports to an empty object in the form of:
|
||||||
`"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
|
`"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
|
||||||
- **HostConfig**
|
- **HostConfig**
|
||||||
- **Binds** – A list of volume bindings for this container. Each volume
|
- **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
|
||||||
binding is a string of the form `container_path` (to create a new
|
+ `container_path` to create a new volume for the container
|
||||||
volume for the container), `host_path:container_path` (to bind-mount
|
+ `host_path:container_path` to bind-mount a host path into the container
|
||||||
a host path into the container), or `host_path:container_path:ro`
|
+ `host_path:container_path:ro` to make the bind-mount read-only inside the container.
|
||||||
(to make the bind-mount read-only inside the container).
|
|
||||||
- **Links** - A list of links for the container. Each link entry should be
|
- **Links** - A list of links for the container. Each link entry should be
|
||||||
in the form of `container_name:alias`.
|
in the form of `container_name:alias`.
|
||||||
- **LxcConf** - LXC specific configurations. These configurations will only
|
- **LxcConf** - LXC specific configurations. These configurations only
|
||||||
work when using the `lxc` execution driver.
|
work when using the `lxc` execution driver.
|
||||||
- **PortBindings** - A map of exposed container ports and the host port they
|
- **PortBindings** - A map of exposed container ports and the host port they
|
||||||
should map to. It should be specified in the form
|
should map to. A JSON object in the form
|
||||||
`{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
|
`{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
|
||||||
Take note that `port` is specified as a string and not an integer value.
|
Take note that `port` is specified as a string and not an integer value.
|
||||||
- **PublishAllPorts** - Allocates a random host port for all of a container's
|
- **PublishAllPorts** - Allocates a random host port for all of a container's
|
||||||
|
@ -242,9 +241,9 @@ Json Parameters:
|
||||||
a boolean value.
|
a boolean value.
|
||||||
- **ReadonlyRootfs** - Mount the container's root filesystem as read only.
|
- **ReadonlyRootfs** - Mount the container's root filesystem as read only.
|
||||||
Specified as a boolean value.
|
Specified as a boolean value.
|
||||||
- **Dns** - A list of dns servers for the container to use.
|
- **Dns** - A list of DNS servers for the container to use.
|
||||||
- **DnsSearch** - A list of DNS search domains
|
- **DnsSearch** - A list of DNS search domains
|
||||||
- **ExtraHosts** - A list of hostnames/IP mappings to be added to the
|
- **ExtraHosts** - A list of hostnames/IP mappings to add to the
|
||||||
container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
|
container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
|
||||||
- **VolumesFrom** - A list of volumes to inherit from another container.
|
- **VolumesFrom** - A list of volumes to inherit from another container.
|
||||||
Specified in the form `<container name>[:<ro|rw>]`
|
Specified in the form `<container name>[:<ro|rw>]`
|
||||||
|
@ -260,19 +259,19 @@ Json Parameters:
|
||||||
is added before each restart to prevent flooding the server.
|
is added before each restart to prevent flooding the server.
|
||||||
- **NetworkMode** - Sets the networking mode for the container. Supported
|
- **NetworkMode** - Sets the networking mode for the container. Supported
|
||||||
values are: `bridge`, `host`, and `container:<name|id>`
|
values are: `bridge`, `host`, and `container:<name|id>`
|
||||||
- **Devices** - A list of devices to add to the container specified in the
|
- **Devices** - A list of devices to add to the container specified as a JSON object in the
|
||||||
form
|
form
|
||||||
`{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
|
`{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
|
||||||
- **Ulimits** - A list of ulimits to be set in the container, specified as
|
- **Ulimits** - A list of ulimits to set in the container, specified as
|
||||||
`{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
|
`{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
|
||||||
`Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
|
`Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
|
||||||
- **SecurityOpt**: A list of string values to customize labels for MLS
|
- **SecurityOpt**: A list of string values to customize labels for MLS
|
||||||
systems, such as SELinux.
|
systems, such as SELinux.
|
||||||
- **LogConfig** - Log configuration for the container, specified as
|
- **LogConfig** - Log configuration for the container, specified as a JSON object in the form
|
||||||
`{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
|
`{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
|
||||||
Available types: `json-file`, `syslog`, `journald`, `none`.
|
Available types: `json-file`, `syslog`, `journald`, `none`.
|
||||||
`json-file` logging driver.
|
`json-file` logging driver.
|
||||||
- **CgroupParent** - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
|
- **CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
|
@ -472,7 +471,7 @@ Status Codes:
|
||||||
|
|
||||||
`GET /containers/(id)/logs`
|
`GET /containers/(id)/logs`
|
||||||
|
|
||||||
Get stdout and stderr logs from the container ``id``
|
Get `stdout` and `stderr` logs from the container ``id``
|
||||||
|
|
||||||
> **Note**:
|
> **Note**:
|
||||||
> This endpoint works only for containers with `json-file` logging driver.
|
> This endpoint works only for containers with `json-file` logging driver.
|
||||||
|
@ -492,14 +491,14 @@ Get stdout and stderr logs from the container ``id``
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **follow** – 1/True/true or 0/False/false, return stream. Default false
|
- **follow** – 1/True/true or 0/False/false, return stream. Default `false`.
|
||||||
- **stdout** – 1/True/true or 0/False/false, show stdout log. Default false
|
- **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`.
|
||||||
- **stderr** – 1/True/true or 0/False/false, show stderr log. Default false
|
- **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`.
|
||||||
- **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
|
- **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
|
||||||
will only output log-entries since that timestamp. Default: 0 (unfiltered)
|
will only output log-entries since that timestamp. Default: 0 (unfiltered)
|
||||||
- **timestamps** – 1/True/true or 0/False/false, print timestamps for
|
- **timestamps** – 1/True/true or 0/False/false, print timestamps for
|
||||||
every log line. Default false
|
every log line. Default `false`.
|
||||||
- **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all
|
- **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -659,7 +658,7 @@ This endpoint returns a live stream of a container's resource usage statistics.
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default true
|
- **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -671,7 +670,7 @@ Status Codes:
|
||||||
|
|
||||||
`POST /containers/(id)/resize?h=<height>&w=<width>`
|
`POST /containers/(id)/resize?h=<height>&w=<width>`
|
||||||
|
|
||||||
Resize the TTY for container with `id`. The container must be restarted for the resize to take effect.
|
Resize the TTY for container with `id`. You must restart the container for the resize to take effect.
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
@ -733,17 +732,16 @@ Start the container `id`
|
||||||
|
|
||||||
Json Parameters:
|
Json Parameters:
|
||||||
|
|
||||||
- **Binds** – A list of volume bindings for this container. Each volume
|
- **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
|
||||||
binding is a string of the form `container_path` (to create a new
|
+ `container_path` to create a new volume for the container
|
||||||
volume for the container), `host_path:container_path` (to bind-mount
|
+ `host_path:container_path` to bind-mount a host path into the container
|
||||||
a host path into the container), or `host_path:container_path:ro`
|
+ `host_path:container_path:ro` to make the bind-mount read-only inside the container.
|
||||||
(to make the bind-mount read-only inside the container).
|
|
||||||
- **Links** - A list of links for the container. Each link entry should be of
|
- **Links** - A list of links for the container. Each link entry should be of
|
||||||
of the form `container_name:alias`.
|
of the form `container_name:alias`.
|
||||||
- **LxcConf** - LXC specific configurations. These configurations will only
|
- **LxcConf** - LXC specific configurations. These configurations only
|
||||||
work when using the `lxc` execution driver.
|
work when using the `lxc` execution driver.
|
||||||
- **PortBindings** - A map of exposed container ports and the host port they
|
- **PortBindings** - A map of exposed container ports and the host port they
|
||||||
should map to. It should be specified in the form
|
should map to. A JSON object in the form
|
||||||
`{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
|
`{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
|
||||||
Take note that `port` is specified as a string and not an integer value.
|
Take note that `port` is specified as a string and not an integer value.
|
||||||
- **PublishAllPorts** - Allocates a random host port for all of a container's
|
- **PublishAllPorts** - Allocates a random host port for all of a container's
|
||||||
|
@ -753,8 +751,8 @@ Json Parameters:
|
||||||
- **ReadonlyRootfs** - Mount the container's root filesystem as read only.
|
- **ReadonlyRootfs** - Mount the container's root filesystem as read only.
|
||||||
Specified as a boolean value.
|
Specified as a boolean value.
|
||||||
- **Dns** - A list of dns servers for the container to use.
|
- **Dns** - A list of dns servers for the container to use.
|
||||||
- **DnsSearch** - A list of DNS search domains
|
- **DnsSearch** - A list of DNS search domains.
|
||||||
- **ExtraHosts** - A list of hostnames/IP mappings to be added to the
|
- **ExtraHosts** - A list of hostnames/IP mappings to add to the
|
||||||
container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
|
container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
|
||||||
- **VolumesFrom** - A list of volumes to inherit from another container.
|
- **VolumesFrom** - A list of volumes to inherit from another container.
|
||||||
Specified in the form `<container name>[:<ro|rw>]`
|
Specified in the form `<container name>[:<ro|rw>]`
|
||||||
|
@ -770,10 +768,10 @@ Json Parameters:
|
||||||
is added before each restart to prevent flooding the server.
|
is added before each restart to prevent flooding the server.
|
||||||
- **NetworkMode** - Sets the networking mode for the container. Supported
|
- **NetworkMode** - Sets the networking mode for the container. Supported
|
||||||
values are: `bridge`, `host`, and `container:<name|id>`
|
values are: `bridge`, `host`, and `container:<name|id>`
|
||||||
- **Devices** - A list of devices to add to the container specified in the
|
- **Devices** - A list of devices to add to the container specified as a JSON object in the
|
||||||
form
|
form
|
||||||
`{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
|
`{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
|
||||||
- **Ulimits** - A list of ulimits to be set in the container, specified as
|
- **Ulimits** - A list of ulimits to set in the container, specified as
|
||||||
`{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
|
`{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
|
||||||
`Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
|
`Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
|
||||||
- **SecurityOpt**: A list of string values to customize labels for MLS
|
- **SecurityOpt**: A list of string values to customize labels for MLS
|
||||||
|
@ -782,7 +780,7 @@ Json Parameters:
|
||||||
`{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
|
`{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
|
||||||
Available types: `json-file`, `syslog`, `journald`, `none`.
|
Available types: `json-file`, `syslog`, `journald`, `none`.
|
||||||
`json-file` logging driver.
|
`json-file` logging driver.
|
||||||
- **CgroupParent** - Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.
|
- **CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -856,8 +854,8 @@ Kill the container `id`
|
||||||
|
|
||||||
Query Parameters
|
Query Parameters
|
||||||
|
|
||||||
- **signal** - Signal to send to the container: integer or string like "SIGINT".
|
- **signal** - Signal to send to the container: integer or string like `SIGINT`.
|
||||||
When not set, SIGKILL is assumed and the call will waits for the container to exit.
|
When not set, `SIGKILL` is assumed and the call waits for the container to exit.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -951,15 +949,15 @@ Attach to the container `id`
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **logs** – 1/True/true or 0/False/false, return logs. Default false
|
- **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
|
||||||
- **stream** – 1/True/true or 0/False/false, return stream.
|
- **stream** – 1/True/true or 0/False/false, return stream.
|
||||||
Default false
|
Default `false`.
|
||||||
- **stdin** – 1/True/true or 0/False/false, if stream=true, attach
|
- **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
|
||||||
to stdin. Default false
|
to `stdin`. Default `false`.
|
||||||
- **stdout** – 1/True/true or 0/False/false, if logs=true, return
|
- **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
|
||||||
stdout log, if stream=true, attach to stdout. Default false
|
`stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
|
||||||
- **stderr** – 1/True/true or 0/False/false, if logs=true, return
|
- **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
|
||||||
stderr log, if stream=true, attach to stderr. Default false
|
`stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -974,30 +972,30 @@ Status Codes:
|
||||||
When using the TTY setting is enabled in
|
When using the TTY setting is enabled in
|
||||||
[`POST /containers/create`
|
[`POST /containers/create`
|
||||||
](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
|
](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
|
||||||
the stream is the raw data from the process PTY and client's stdin.
|
the stream is the raw data from the process PTY and client's `stdin`.
|
||||||
When the TTY is disabled, then the stream is multiplexed to separate
|
When the TTY is disabled, then the stream is multiplexed to separate
|
||||||
stdout and stderr.
|
`stdout` and `stderr`.
|
||||||
|
|
||||||
The format is a **Header** and a **Payload** (frame).
|
The format is a **Header** and a **Payload** (frame).
|
||||||
|
|
||||||
**HEADER**
|
**HEADER**
|
||||||
|
|
||||||
The header will contain the information on which stream write the
|
The header contains the information which the stream writes (`stdout` or
|
||||||
stream (stdout or stderr). It also contain the size of the
|
`stderr`). It also contains the size of the associated frame encoded in the
|
||||||
associated frame encoded on the last 4 bytes (uint32).
|
last four bytes (`uint32`).
|
||||||
|
|
||||||
It is encoded on the first 8 bytes like this:
|
It is encoded on the first eight bytes like this:
|
||||||
|
|
||||||
header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
|
||||||
|
|
||||||
`STREAM_TYPE` can be:
|
`STREAM_TYPE` can be:
|
||||||
|
|
||||||
- 0: stdin (will be written on stdout)
|
- 0: `stdin` (is written on `stdout`)
|
||||||
- 1: stdout
|
- 1: `stdout`
|
||||||
- 2: stderr
|
- 2: `stderr`
|
||||||
|
|
||||||
`SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
|
`SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
|
||||||
the uint32 size encoded as big endian.
|
the `uint32` size encoded as big endian.
|
||||||
|
|
||||||
**PAYLOAD**
|
**PAYLOAD**
|
||||||
|
|
||||||
|
@ -1007,11 +1005,11 @@ Status Codes:
|
||||||
|
|
||||||
The simplest way to implement the Attach protocol is the following:
|
The simplest way to implement the Attach protocol is the following:
|
||||||
|
|
||||||
1. Read 8 bytes
|
1. Read eight bytes.
|
||||||
2. chose stdout or stderr depending on the first byte
|
2. Choose `stdout` or `stderr` depending on the first byte.
|
||||||
3. Extract the frame size from the last 4 bytes
|
3. Extract the frame size from the last four bytes.
|
||||||
4. Read the extracted size and output it on the correct output
|
4. Read the extracted size and output it on the correct output.
|
||||||
5. Goto 1
|
5. Goto 1.
|
||||||
|
|
||||||
### Attach to a container (websocket)
|
### Attach to a container (websocket)
|
||||||
|
|
||||||
|
@ -1031,15 +1029,15 @@ Implements websocket protocol handshake according to [RFC 6455](http://tools.iet
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **logs** – 1/True/true or 0/False/false, return logs. Default false
|
- **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
|
||||||
- **stream** – 1/True/true or 0/False/false, return stream.
|
- **stream** – 1/True/true or 0/False/false, return stream.
|
||||||
Default false
|
Default `false`.
|
||||||
- **stdin** – 1/True/true or 0/False/false, if stream=true, attach
|
- **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
|
||||||
to stdin. Default false
|
to `stdin`. Default `false`.
|
||||||
- **stdout** – 1/True/true or 0/False/false, if logs=true, return
|
- **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
|
||||||
stdout log, if stream=true, attach to stdout. Default false
|
`stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
|
||||||
- **stderr** – 1/True/true or 0/False/false, if logs=true, return
|
- **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
|
||||||
stderr log, if stream=true, attach to stderr. Default false
|
`stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -1088,9 +1086,9 @@ Remove the container `id` from the filesystem
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **v** – 1/True/true or 0/False/false, Remove the volumes
|
- **v** – 1/True/true or 0/False/false, Remove the volumes
|
||||||
associated to the container. Default false
|
associated to the container. Default `false`.
|
||||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||||
Default false
|
Default `false`.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -1210,9 +1208,9 @@ references on the command line.
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **all** – 1/True/true or 0/False/false, default false
|
- **all** – 1/True/true or 0/False/false, default false
|
||||||
- **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
- **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
|
||||||
- dangling=true
|
- `dangling=true`
|
||||||
- label=`key` or `key=value` of an image label
|
- `label=key` or `key=value` of an image label
|
||||||
|
|
||||||
### Build image from a Dockerfile
|
### Build image from a Dockerfile
|
||||||
|
|
||||||
|
@ -1235,43 +1233,43 @@ Build an image from a Dockerfile
|
||||||
{"stream": "..."}
|
{"stream": "..."}
|
||||||
{"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
|
{"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
|
||||||
|
|
||||||
The input stream must be a tar archive compressed with one of the
|
The input stream must be a `tar` archive compressed with one of the
|
||||||
following algorithms: identity (no compression), gzip, bzip2, xz.
|
following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
|
||||||
|
|
||||||
The archive must include a build instructions file, typically called
|
The archive must include a build instructions file, typically called
|
||||||
`Dockerfile` at the root of the archive. The `dockerfile` parameter may be
|
`Dockerfile` at the archive's root. The `dockerfile` parameter may be
|
||||||
used to specify a different build instructions file by having its value be
|
used to specify a different build instructions file. To do this, its value must be
|
||||||
the path to the alternate build instructions file to use.
|
the path to the alternate build instructions file to use.
|
||||||
|
|
||||||
The archive may include any number of other files,
|
The archive may include any number of other files,
|
||||||
which will be accessible in the build context (See the [*ADD build
|
which are accessible in the build context (See the [*ADD build
|
||||||
command*](/reference/builder/#dockerbuilder)).
|
command*](/reference/builder/#dockerbuilder)).
|
||||||
|
|
||||||
The build will also be canceled if the client drops the connection by quitting
|
The build is canceled if the client drops the connection by quitting
|
||||||
or being killed.
|
or being killed.
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **dockerfile** - path within the build context to the Dockerfile. This is
|
- **dockerfile** - Path within the build context to the Dockerfile. This is
|
||||||
ignored if `remote` is specified and points to an individual filename.
|
ignored if `remote` is specified and points to an individual filename.
|
||||||
- **t** – repository name (and optionally a tag) to be applied to
|
- **t** – A repository name (and optionally a tag) to apply to
|
||||||
the resulting image in case of success
|
the resulting image in case of success.
|
||||||
- **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the
|
- **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the
|
||||||
URI specifies a filename, the file's contents are placed into a file
|
URI specifies a filename, the file's contents are placed into a file
|
||||||
called `Dockerfile`.
|
called `Dockerfile`.
|
||||||
- **q** – suppress verbose build output
|
- **q** – Suppress verbose build output.
|
||||||
- **nocache** – do not use the cache when building the image
|
- **nocache** – Do not use the cache when building the image.
|
||||||
- **pull** - attempt to pull the image even if an older image exists locally
|
- **pull** - Attempt to pull the image even if an older image exists locally.
|
||||||
- **rm** - remove intermediate containers after a successful build (default behavior)
|
- **rm** - Remove intermediate containers after a successful build (default behavior).
|
||||||
- **forcerm** - always remove intermediate containers (includes rm)
|
- **forcerm** - Always remove intermediate containers (includes `rm`).
|
||||||
- **memory** - set memory limit for build
|
- **memory** - Set memory limit for build.
|
||||||
- **memswap** - Total memory (memory + swap), `-1` to disable swap
|
- **memswap** - Total memory (memory + swap), `-1` to disable swap.
|
||||||
- **cpushares** - CPU shares (relative weight)
|
- **cpushares** - CPU shares (relative weight).
|
||||||
- **cpusetcpus** - CPUs in which to allow execution, e.g., `0-3`, `0,1`
|
- **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
|
||||||
|
|
||||||
Request Headers:
|
Request Headers:
|
||||||
|
|
||||||
- **Content-type** – should be set to `"application/tar"`.
|
- **Content-type** – Set to `"application/tar"`.
|
||||||
- **X-Registry-Config** – base64-encoded ConfigFile object
|
- **X-Registry-Config** – base64-encoded ConfigFile object
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
@ -1283,7 +1281,7 @@ Status Codes:
|
||||||
|
|
||||||
`POST /images/create`
|
`POST /images/create`
|
||||||
|
|
||||||
Create an image, either by pulling it from the registry or by importing it
|
Create an image either by pulling it from the registry or by importing it
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
@ -1299,18 +1297,18 @@ Create an image, either by pulling it from the registry or by importing it
|
||||||
{"error": "Invalid..."}
|
{"error": "Invalid..."}
|
||||||
...
|
...
|
||||||
|
|
||||||
When using this endpoint to pull an image from the registry, the
|
When using this endpoint to pull an image from the registry, the
|
||||||
`X-Registry-Auth` header can be used to include
|
`X-Registry-Auth` header can be used to include
|
||||||
a base64-encoded AuthConfig object.
|
a base64-encoded AuthConfig object.
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **fromImage** – name of the image to pull
|
- **fromImage** – Name of the image to pull.
|
||||||
- **fromSrc** – source to import. The value may be a URL from which the image
|
- **fromSrc** – Source to import. The value may be a URL from which the image
|
||||||
can be retrieved or `-` to read the image from the request body.
|
can be retrieved or `-` to read the image from the request body.
|
||||||
- **repo** – repository
|
- **repo** – Repository name.
|
||||||
- **tag** – tag
|
- **tag** – Tag.
|
||||||
- **registry** – the registry to pull from
|
- **registry** – The registry to pull from.
|
||||||
|
|
||||||
Request Headers:
|
Request Headers:
|
||||||
|
|
||||||
|
@ -1430,9 +1428,9 @@ Push the image `name` on the registry
|
||||||
{"error": "Invalid..."}
|
{"error": "Invalid..."}
|
||||||
...
|
...
|
||||||
|
|
||||||
If you wish to push an image on to a private registry, that image must already have been tagged
|
If you wish to push an image on to a private registry, that image must already have a tag
|
||||||
into a repository which references that registry host name and port. This repository name should
|
into a repository which references that registry `hostname` and `port`. This repository name should
|
||||||
then be used in the URL. This mirrors the flow of the CLI.
|
then be used in the URL. This duplicates the command line's flow.
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
@ -1441,11 +1439,11 @@ Push the image `name` on the registry
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **tag** – the tag to associate with the image on the registry, optional
|
- **tag** – The tag to associate with the image on the registry. This is optional.
|
||||||
|
|
||||||
Request Headers:
|
Request Headers:
|
||||||
|
|
||||||
- **X-Registry-Auth** – include a base64-encoded AuthConfig
|
- **X-Registry-Auth** – Include a base64-encoded AuthConfig.
|
||||||
object.
|
object.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
@ -1788,11 +1786,11 @@ Status Codes:
|
||||||
Get container events from docker, either in real time via streaming, or via
|
Get container events from docker, either in real time via streaming, or via
|
||||||
polling (using since).
|
polling (using since).
|
||||||
|
|
||||||
Docker containers will report the following events:
|
Docker containers report the following events:
|
||||||
|
|
||||||
create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
|
create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
|
||||||
|
|
||||||
and Docker images will report:
|
and Docker images report:
|
||||||
|
|
||||||
untag, delete
|
untag, delete
|
||||||
|
|
||||||
|
@ -1812,12 +1810,12 @@ and Docker images will report:
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **since** – timestamp used for polling
|
- **since** – Timestamp used for polling
|
||||||
- **until** – timestamp used for polling
|
- **until** – Timestamp used for polling
|
||||||
- **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
|
- **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
|
||||||
- event=<string> -- event to filter
|
- `event=<string>`; -- event to filter
|
||||||
- image=<string> -- image to filter
|
- `image=<string>`; -- image to filter
|
||||||
- container=<string> -- container to filter
|
- `container=<string>`; -- container to filter
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -1861,7 +1859,7 @@ Status Codes:
|
||||||
Get a tarball containing all images and metadata for one or more repositories.
|
Get a tarball containing all images and metadata for one or more repositories.
|
||||||
|
|
||||||
For each value of the `names` parameter: if it is a specific name and tag (e.g.
|
For each value of the `names` parameter: if it is a specific name and tag (e.g.
|
||||||
ubuntu:latest), then only that image (and its parents) are returned; if it is
|
`ubuntu:latest`), then only that image (and its parents) are returned; if it is
|
||||||
an image ID, similarly only that image (and its parents) are returned and there
|
an image ID, similarly only that image (and its parents) are returned and there
|
||||||
would be no names referenced in the 'repositories' file for this image ID.
|
would be no names referenced in the 'repositories' file for this image ID.
|
||||||
|
|
||||||
|
@ -1887,7 +1885,7 @@ Status Codes:
|
||||||
|
|
||||||
`POST /images/load`
|
`POST /images/load`
|
||||||
|
|
||||||
Load a set of images and tags into the docker repository.
|
Load a set of images and tags into a Docker repository.
|
||||||
See the [image tarball format](#image-tarball-format) for more details.
|
See the [image tarball format](#image-tarball-format) for more details.
|
||||||
|
|
||||||
**Example request**
|
**Example request**
|
||||||
|
@ -1908,16 +1906,16 @@ Status Codes:
|
||||||
### Image tarball format
|
### Image tarball format
|
||||||
|
|
||||||
An image tarball contains one directory per image layer (named using its long ID),
|
An image tarball contains one directory per image layer (named using its long ID),
|
||||||
each containing three files:
|
each containing these files:
|
||||||
|
|
||||||
1. `VERSION`: currently `1.0` - the file format version
|
- `VERSION`: currently `1.0` - the file format version
|
||||||
2. `json`: detailed layer information, similar to `docker inspect layer_id`
|
- `json`: detailed layer information, similar to `docker inspect layer_id`
|
||||||
3. `layer.tar`: A tarfile containing the filesystem changes in this layer
|
- `layer.tar`: A tarfile containing the filesystem changes in this layer
|
||||||
|
|
||||||
The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
|
The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
|
||||||
for storing attribute changes and deletions.
|
for storing attribute changes and deletions.
|
||||||
|
|
||||||
If the tarball defines a repository, there will also be a `repositories` file at
|
If the tarball defines a repository, the tarball should also include a `repositories` file at
|
||||||
the root that contains a list of repository and tag names mapped to layer IDs.
|
the root that contains a list of repository and tag names mapped to layer IDs.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -1959,10 +1957,10 @@ Sets up an exec instance in a running container `id`
|
||||||
|
|
||||||
Json Parameters:
|
Json Parameters:
|
||||||
|
|
||||||
- **AttachStdin** - Boolean value, attaches to stdin of the exec command.
|
- **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
|
||||||
- **AttachStdout** - Boolean value, attaches to stdout of the exec command.
|
- **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
|
||||||
- **AttachStderr** - Boolean value, attaches to stderr of the exec command.
|
- **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
|
||||||
- **Tty** - Boolean value to allocate a pseudo-TTY
|
- **Tty** - Boolean value to allocate a pseudo-TTY.
|
||||||
- **Cmd** - Command to run specified as a string or an array of strings.
|
- **Cmd** - Command to run specified as a string or an array of strings.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1975,7 +1973,7 @@ Status Codes:
|
||||||
|
|
||||||
`POST /exec/(id)/start`
|
`POST /exec/(id)/start`
|
||||||
|
|
||||||
Starts a previously set up exec instance `id`. If `detach` is true, this API
|
Starts a previously set up `exec` instance `id`. If `detach` is true, this API
|
||||||
returns after starting the `exec` command. Otherwise, this API sets up an
|
returns after starting the `exec` command. Otherwise, this API sets up an
|
||||||
interactive session with the `exec` command.
|
interactive session with the `exec` command.
|
||||||
|
|
||||||
|
@ -1998,8 +1996,8 @@ interactive session with the `exec` command.
|
||||||
|
|
||||||
Json Parameters:
|
Json Parameters:
|
||||||
|
|
||||||
- **Detach** - Detach from the exec command
|
- **Detach** - Detach from the `exec` command.
|
||||||
- **Tty** - Boolean value to allocate a pseudo-TTY
|
- **Tty** - Boolean value to allocate a pseudo-TTY.
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
|
||||||
|
@ -2013,8 +2011,8 @@ Status Codes:
|
||||||
|
|
||||||
`POST /exec/(id)/resize`
|
`POST /exec/(id)/resize`
|
||||||
|
|
||||||
Resizes the tty session used by the exec command `id`.
|
Resizes the `tty` session used by the `exec` command `id`.
|
||||||
This API is valid only if `tty` was specified as part of creating and starting the exec command.
|
This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
@ -2028,7 +2026,7 @@ This API is valid only if `tty` was specified as part of creating and starting t
|
||||||
|
|
||||||
Query Parameters:
|
Query Parameters:
|
||||||
|
|
||||||
- **h** – height of tty session
|
- **h** – height of `tty` session
|
||||||
- **w** – width
|
- **w** – width
|
||||||
|
|
||||||
Status Codes:
|
Status Codes:
|
||||||
|
@ -2040,7 +2038,7 @@ Status Codes:
|
||||||
|
|
||||||
`GET /exec/(id)/json`
|
`GET /exec/(id)/json`
|
||||||
|
|
||||||
Return low-level information about the exec command `id`.
|
Return low-level information about the `exec` command `id`.
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
|
@ -2150,22 +2148,21 @@ As an example, the `docker run` command line makes the following API calls:
|
||||||
- Create the container
|
- Create the container
|
||||||
|
|
||||||
- If the status code is 404, it means the image doesn't exist:
|
- If the status code is 404, it means the image doesn't exist:
|
||||||
- Try to pull it
|
- Try to pull it.
|
||||||
- Then retry to create the container
|
- Then, retry to create the container.
|
||||||
|
|
||||||
- Start the container
|
- Start the container.
|
||||||
|
|
||||||
- If you are not in detached mode:
|
- If you are not in detached mode:
|
||||||
- Attach to the container, using logs=1 (to have stdout and
|
- Attach to the container, using `logs=1` (to have `stdout` and
|
||||||
stderr from the container's start) and stream=1
|
`stderr` from the container's start) and `stream=1`
|
||||||
|
|
||||||
- If in detached mode or only stdin is attached:
|
- If in detached mode or only `stdin` is attached, display the container's id.
|
||||||
- Display the container's id
|
|
||||||
|
|
||||||
## 3.2 Hijacking
|
## 3.2 Hijacking
|
||||||
|
|
||||||
In this version of the API, /attach, uses hijacking to transport stdin,
|
In this version of the API, `/attach`, uses hijacking to transport `stdin`,
|
||||||
stdout and stderr on the same socket.
|
`stdout`, and `stderr` on the same socket.
|
||||||
|
|
||||||
To hint potential proxies about connection hijacking, Docker client sends
|
To hint potential proxies about connection hijacking, Docker client sends
|
||||||
connection upgrade headers similarly to websocket.
|
connection upgrade headers similarly to websocket.
|
||||||
|
@ -2173,15 +2170,14 @@ connection upgrade headers similarly to websocket.
|
||||||
Upgrade: tcp
|
Upgrade: tcp
|
||||||
Connection: Upgrade
|
Connection: Upgrade
|
||||||
|
|
||||||
When Docker daemon detects the `Upgrade` header, it will switch its status code
|
When Docker daemon detects the `Upgrade` header, it switches its status code
|
||||||
from **200 OK** to **101 UPGRADED** and resend the same headers.
|
from **200 OK** to **101 UPGRADED** and resends the same headers.
|
||||||
|
|
||||||
This might change in the future.
|
|
||||||
|
|
||||||
## 3.3 CORS Requests
|
## 3.3 CORS Requests
|
||||||
|
|
||||||
To set cross origin requests to the remote api please give values to
|
To set cross origin requests to the remote api please give values to
|
||||||
"--api-cors-header" when running docker in daemon mode. Set * will allow all,
|
`--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
|
||||||
default or blank means CORS disabled
|
default or blank means CORS disabled
|
||||||
|
|
||||||
$ docker -d -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"
|
$ docker -d -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"
|
||||||
|
|
Loading…
Reference in New Issue