github.com/kim0/docker@v0.6.2-0.20161130212042-4addda3f07e7/docs/reference/api/docker_remote_api.md (about)

     1  ---
     2  title: "Remote API"
     3  description: "API Documentation for Docker"
     4  keywords: ["API, Docker, rcli, REST,  documentation"]
     5  ---
     6  
     7  <!-- This file is maintained within the docker/docker Github
     8       repository at https://github.com/docker/docker/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # Docker Remote API
    17  
    18  Docker's Remote API uses an open schema model.  In this model, unknown
    19  properties in incoming messages are ignored. Client applications need to take
    20  this behavior into account to ensure they do not break when talking to newer
    21  Docker daemons.
    22  
    23  The API tends to be REST, but for some complex commands, like attach or pull,
    24  the HTTP connection is hijacked to transport STDOUT, STDIN, and STDERR.
    25  
    26  By default the Docker daemon listens on `unix:///var/run/docker.sock` and the
    27  client must have `root` access to interact with the daemon. If a group named
    28  `docker` exists on your system, `docker` applies ownership of the socket to the
    29  group.
    30  
    31  To connect to the Docker daemon with cURL you need to use cURL 7.40 or
    32  later, as these versions have the `--unix-socket` flag available. To
    33  run `curl` against the daemon on the default socket, use the
    34  following:
    35  
    36  When using cUrl 7.50 or later:
    37  
    38  ```console
    39  $ curl --unix-socket /var/run/docker.sock http://localhost/containers/json
    40  ```
    41  
    42  When using cURL 7.40, `localhost` must be omitted:
    43  
    44  ```console
    45  $ curl --unix-socket /var/run/docker.sock http://containers/json
    46  ```
    47  
    48  If you have bound the Docker daemon to a different socket path or TCP
    49  port, you would reference that in your cURL rather than the
    50  default.
    51  
    52  The current version of the API is v1.25 which means calling `/info` is the same
    53  as calling `/v1.25/info`. To call an older version of the API use
    54  `/v1.24/info`. If a newer daemon is installed, new properties may be returned
    55  even when calling older versions of the API.
    56  
    57  Use the table below to find the API version for a Docker version:
    58  
    59  Docker version  | API version                        | Changes
    60  ----------------|------------------------------------|------------------------------------------------------
    61  1.13.x          | [1.25](docker_remote_api_v1.25.md) | [API changes](docker_remote_api.md#v1-25-api-changes)
    62  1.12.x          | [1.24](docker_remote_api_v1.24.md) | [API changes](docker_remote_api.md#v1-24-api-changes)
    63  1.11.x          | [1.23](docker_remote_api_v1.23.md) | [API changes](docker_remote_api.md#v1-23-api-changes)
    64  1.10.x          | [1.22](docker_remote_api_v1.22.md) | [API changes](docker_remote_api.md#v1-22-api-changes)
    65  1.9.x           | [1.21](docker_remote_api_v1.21.md) | [API changes](docker_remote_api.md#v1-21-api-changes)
    66  1.8.x           | [1.20](docker_remote_api_v1.20.md) | [API changes](docker_remote_api.md#v1-20-api-changes)
    67  1.7.x           | [1.19](docker_remote_api_v1.19.md) | [API changes](docker_remote_api.md#v1-19-api-changes)
    68  1.6.x           | [1.18](docker_remote_api_v1.18.md) | [API changes](docker_remote_api.md#v1-18-api-changes)
    69  
    70  Refer to the [GitHub repository](
    71  https://github.com/docker/docker/tree/master/docs/reference/api) for
    72  older releases.
    73  
    74  ## Authentication
    75  
    76  Authentication configuration is handled client side, so the
    77  client has to send the `authConfig` as a `POST` in `/images/(name)/push`. The
    78  `authConfig`, set as the `X-Registry-Auth` header, is currently a Base64 encoded
    79  (JSON) string with the following structure:
    80  
    81  ```JSON
    82  {"username": "string", "password": "string", "email": "string",
    83     "serveraddress" : "string", "auth": ""}
    84  ```
    85  
    86  Callers should leave the `auth` empty. The `serveraddress` is a domain/ip
    87  without protocol. Throughout this structure, double quotes are required.
    88  
    89  ## Using Docker Machine with the API
    90  
    91  If you are using `docker-machine`, the Docker daemon is on a host that
    92  uses an encrypted TCP socket using TLS. This means, for Docker Machine users,
    93  you need to add extra parameters to `curl` or `wget` when making test
    94  API requests, for example:
    95  
    96  ```
    97  curl --insecure \
    98       --cert $DOCKER_CERT_PATH/cert.pem \
    99       --key $DOCKER_CERT_PATH/key.pem \
   100       https://YOUR_VM_IP:2376/images/json
   101  
   102  wget --no-check-certificate --certificate=$DOCKER_CERT_PATH/cert.pem \
   103       --private-key=$DOCKER_CERT_PATH/key.pem \
   104       https://YOUR_VM_IP:2376/images/json -O - -q
   105  ```
   106  
   107  ## Docker Events
   108  
   109  The following diagram depicts the container states accessible through the API.
   110  
   111  ![States](images/event_state.png)
   112  
   113  Some container-related events are not affected by container state, so they are not included in this diagram. These events are:
   114  
   115  * **export** emitted by `docker export`
   116  * **exec_create** emitted by `docker exec`
   117  * **exec_start** emitted by `docker exec` after **exec_create**
   118  * **detach** emitted when client is detached from container process
   119  * **exec_detach** emitted when client is detached from exec process
   120  
   121  Running `docker rmi` emits an **untag** event when removing an image name.  The `rmi` command may also emit **delete** events when images are deleted by ID directly or by deleting the last tag referring to the image.
   122  
   123  > **Acknowledgment**: This diagram and the accompanying text were used with the permission of Matt Good and Gilder Labs. See Matt's original blog post [Docker Events Explained](https://gliderlabs.com/blog/2015/04/14/docker-events-explained/).
   124  
   125  ## Version history
   126  
   127  This section lists each version from latest to oldest.  Each listing includes a link to the full documentation set and the changes relevant in that release.
   128  
   129  ### v1.25 API changes
   130  
   131  [Docker Remote API v1.25](docker_remote_api_v1.25.md) documentation
   132  
   133  * `POST /build` accepts `networkmode` parameter to specify network used during build.
   134  * `GET /images/(name)/json` now returns `OsVersion` if populated
   135  * `GET /info` now returns `Isolation`.
   136  * `POST /containers/create` now takes `AutoRemove` in HostConfig, to enable auto-removal of the container on daemon side when the container's process exits.
   137  * `GET /containers/json` and `GET /containers/(id or name)/json` now return `"removing"` as a value for the `State.Status` field if the container is being removed. Previously, "exited" was returned as status.
   138  * `GET /containers/json` now accepts `removing` as a valid value for the `status` filter.
   139  * `GET /containers/json` now supports filtering containers by `health` status. 
   140  * `DELETE /volumes/(name)` now accepts a `force` query parameter to force removal of volumes that were already removed out of band by the volume driver plugin.
   141  * `POST /containers/create/` and `POST /containers/(name)/update` now validates restart policies.
   142  * `POST /containers/create` now validates IPAMConfig in NetworkingConfig, and returns error for invalid IPv4 and IPv6 addresses (`--ip` and `--ip6` in `docker create/run`).
   143  * `POST /containers/create` now takes a `Mounts` field in `HostConfig` which replaces `Binds`, `Volumes`, and `Tmpfs`. *note*: `Binds`, `Volumes`, and `Tmpfs` are still available and can be combined with `Mounts`.
   144  * `POST /build` now performs a preliminary validation of the `Dockerfile` before starting the build, and returns an error if the syntax is incorrect. Note that this change is _unversioned_ and applied to all API versions.
   145  * `POST /build` accepts `cachefrom` parameter to specify images used for build cache.
   146  * `GET /networks/` endpoint now correctly returns a list of *all* networks,
   147    instead of the default network if a trailing slash is provided, but no `name`
   148    or `id`.
   149  * `DELETE /containers/(name)` endpoint now returns an error of `removal of container name is already in progress` with status code of 400, when container name is in a state of removal in progress.
   150  * `GET /containers/json` now supports a `is-task` filter to filter
   151    containers that are tasks (part of a service in swarm mode).
   152  * `POST /containers/create` now takes `StopTimeout` field.
   153  * `POST /services/create` and `POST /services/(id or name)/update` now accept `Monitor` and `MaxFailureRatio` parameters, which control the response to failures during service updates.
   154  * `POST /services/(id or name)/update` now accepts a `ForceUpdate` parameter inside the `TaskTemplate`, which causes the service to be updated even if there are no changes which would ordinarily trigger an update.
   155  * `GET /networks/(name)` now returns field `Created` in response to show network created time.
   156  * `POST /containers/(id or name)/exec` now accepts an `Env` field, which holds a list of environment variables to be set in the context of the command execution.
   157  * `GET /volumes`, `GET /volumes/(name)`, and `POST /volumes/create` now return the `Options` field which holds the driver specific options to use for when creating the volume.
   158  * `GET /exec/(id)/json` now returns `Pid`, which is the system pid for the exec'd process.
   159  * `POST /containers/prune` prunes stopped containers.
   160  * `POST /images/prune` prunes unused images.
   161  * `POST /volumes/prune` prunes unused volumes.
   162  * `POST /networks/prune` prunes unused networks.
   163  * Every API response now includes a `Docker-Experimental` header specifying if experimental features are enabled (value can be `true` or `false`).
   164  * The `hostConfig` option now accepts the fields `CpuRealtimePeriod` and `CpuRtRuntime` to allocate cpu runtime to rt tasks when `CONFIG_RT_GROUP_SCHED` is enabled in the kernel.
   165  * The `SecurityOptions` field within the `GET /info` response now includes `userns` if user namespaces are enabled in the daemon.
   166  
   167  ### v1.24 API changes
   168  
   169  [Docker Remote API v1.24](docker_remote_api_v1.24.md) documentation
   170  
   171  * `POST /containers/create` now takes `StorageOpt` field.
   172  * `GET /info` now returns `SecurityOptions` field, showing if `apparmor`, `seccomp`, or `selinux` is supported.
   173  * `GET /info` no longer returns the `ExecutionDriver` property. This property was no longer used after integration
   174    with ContainerD in Docker 1.11.
   175  * `GET /networks` now supports filtering by `label` and `driver`.
   176  * `GET /containers/json` now supports filtering containers by `network` name or id.
   177  * `POST /containers/create` now takes `IOMaximumBandwidth` and `IOMaximumIOps` fields. Windows daemon only.
   178  * `POST /containers/create` now returns an HTTP 400 "bad parameter" message
   179    if no command is specified (instead of an HTTP 500 "server error")
   180  * `GET /images/search` now takes a `filters` query parameter.
   181  * `GET /events` now supports a `reload` event that is emitted when the daemon configuration is reloaded.
   182  * `GET /events` now supports filtering by daemon name or ID.
   183  * `GET /events` now supports a `detach` event that is emitted on detaching from container process.
   184  * `GET /events` now supports an `exec_detach ` event that is emitted on detaching from exec process.
   185  * `GET /images/json` now supports filters `since` and `before`.
   186  * `POST /containers/(id or name)/start` no longer accepts a `HostConfig`.
   187  * `POST /images/(name)/tag` no longer has a `force` query parameter.
   188  * `GET /images/search` now supports maximum returned search results `limit`.
   189  * `POST /containers/{name:.*}/copy` is now removed and errors out starting from this API version.
   190  * API errors are now returned as JSON instead of plain text.
   191  * `POST /containers/create` and `POST /containers/(id)/start` allow you to configure kernel parameters (sysctls) for use in the container.
   192  * `POST /containers/<container ID>/exec` and `POST /exec/<exec ID>/start`
   193    no longer expects a "Container" field to be present. This property was not used
   194    and is no longer sent by the docker client.
   195  * `POST /containers/create/` now validates the hostname (should be a valid RFC 1123 hostname).
   196  * `POST /containers/create/` `HostConfig.PidMode` field now accepts `container:<name|id>`,
   197    to have the container join the PID namespace of an existing container.
   198  
   199  ### v1.23 API changes
   200  
   201  [Docker Remote API v1.23](docker_remote_api_v1.23.md) documentation
   202  
   203  * `GET /containers/json` returns the state of the container, one of `created`, `restarting`, `running`, `paused`, `exited` or `dead`.
   204  * `GET /containers/json` returns the mount points for the container.
   205  * `GET /networks/(name)` now returns an `Internal` field showing whether the network is internal or not.
   206  * `GET /networks/(name)` now returns an `EnableIPv6` field showing whether the network has ipv6 enabled or not.
   207  * `POST /containers/(name)/update` now supports updating container's restart policy.
   208  * `POST /networks/create` now supports enabling ipv6 on the network by setting the `EnableIPv6` field (doing this with a label will no longer work).
   209  * `GET /info` now returns `CgroupDriver` field showing what cgroup driver the daemon is using; `cgroupfs` or `systemd`.
   210  * `GET /info` now returns `KernelMemory` field, showing if "kernel memory limit" is supported.
   211  * `POST /containers/create` now takes `PidsLimit` field, if the kernel is >= 4.3 and the pids cgroup is supported.
   212  * `GET /containers/(id or name)/stats` now returns `pids_stats`, if the kernel is >= 4.3 and the pids cgroup is supported.
   213  * `POST /containers/create` now allows you to override usernamespaces remapping and use privileged options for the container.
   214  * `POST /containers/create` now allows specifying `nocopy` for named volumes, which disables automatic copying from the container path to the volume.
   215  * `POST /auth` now returns an `IdentityToken` when supported by a registry.
   216  * `POST /containers/create` with both `Hostname` and `Domainname` fields specified will result in the container's hostname being set to `Hostname`, rather than `Hostname.Domainname`.
   217  * `GET /volumes` now supports more filters, new added filters are `name` and `driver`.
   218  * `GET /containers/(id or name)/logs` now accepts a `details` query parameter to stream the extra attributes that were provided to the containers `LogOpts`, such as environment variables and labels, with the logs.
   219  * `POST /images/load` now returns progress information as a JSON stream, and has a `quiet` query parameter to suppress progress details.
   220  
   221  ### v1.22 API changes
   222  
   223  [Docker Remote API v1.22](docker_remote_api_v1.22.md) documentation
   224  
   225  * `POST /container/(name)/update` updates the resources of a container.
   226  * `GET /containers/json` supports filter `isolation` on Windows.
   227  * `GET /containers/json` now returns the list of networks of containers.
   228  * `GET /info` Now returns `Architecture` and `OSType` fields, providing information
   229    about the host architecture and operating system type that the daemon runs on.
   230  * `GET /networks/(name)` now returns a `Name` field for each container attached to the network.
   231  * `GET /version` now returns the `BuildTime` field in RFC3339Nano format to make it
   232    consistent with other date/time values returned by the API.
   233  * `AuthConfig` now supports a `registrytoken` for token based authentication
   234  * `POST /containers/create` now has a 4M minimum value limit for `HostConfig.KernelMemory`
   235  * Pushes initiated with `POST /images/(name)/push` and pulls initiated with `POST /images/create`
   236    will be cancelled if the HTTP connection making the API request is closed before
   237    the push or pull completes.
   238  * `POST /containers/create` now allows you to set a read/write rate limit for a
   239    device (in bytes per second or IO per second).
   240  * `GET /networks` now supports filtering by `name`, `id` and `type`.
   241  * `POST /containers/create` now allows you to set the static IPv4 and/or IPv6 address for the container.
   242  * `POST /networks/(id)/connect` now allows you to set the static IPv4 and/or IPv6 address for the container.
   243  * `GET /info` now includes the number of containers running, stopped, and paused.
   244  * `POST /networks/create` now supports restricting external access to the network by setting the `Internal` field.
   245  * `POST /networks/(id)/disconnect` now includes a `Force` option to forcefully disconnect a container from network
   246  * `GET /containers/(id)/json` now returns the `NetworkID` of containers.
   247  * `POST /networks/create` Now supports an options field in the IPAM config that provides options
   248    for custom IPAM plugins.
   249  * `GET /networks/{network-id}` Now returns IPAM config options for custom IPAM plugins if any
   250    are available.
   251  * `GET /networks/<network-id>` now returns subnets info for user-defined networks.
   252  * `GET /info` can now return a `SystemStatus` field useful for returning additional information about applications
   253    that are built on top of engine.
   254  
   255  ### v1.21 API changes
   256  
   257  [Docker Remote API v1.21](docker_remote_api_v1.21.md) documentation
   258  
   259  * `GET /volumes` lists volumes from all volume drivers.
   260  * `POST /volumes/create` to create a volume.
   261  * `GET /volumes/(name)` get low-level information about a volume.
   262  * `DELETE /volumes/(name)` remove a volume with the specified name.
   263  * `VolumeDriver` was moved from `config` to `HostConfig` to make the configuration portable.
   264  * `GET /images/(name)/json` now returns information about an image's `RepoTags` and `RepoDigests`.
   265  * The `config` option now accepts the field `StopSignal`, which specifies the signal to use to kill a container.
   266  * `GET /containers/(id)/stats` will return networking information respectively for each interface.
   267  * The `HostConfig` option now includes the `DnsOptions` field to configure the container's DNS options.
   268  * `POST /build` now optionally takes a serialized map of build-time variables.
   269  * `GET /events` now includes a `timenano` field, in addition to the existing `time` field.
   270  * `GET /events` now supports filtering by image and container labels.
   271  * `GET /info` now lists engine version information and return the information of `CPUShares` and `Cpuset`.
   272  * `GET /containers/json` will return `ImageID` of the image used by container.
   273  * `POST /exec/(name)/start` will now return an HTTP 409 when the container is either stopped or paused.
   274  * `POST /containers/create` now takes `KernelMemory` in HostConfig to specify kernel memory limit.
   275  * `GET /containers/(name)/json` now accepts a `size` parameter. Setting this parameter to '1' returns container size information in the `SizeRw` and `SizeRootFs` fields.
   276  * `GET /containers/(name)/json` now returns a `NetworkSettings.Networks` field,
   277    detailing network settings per network. This field deprecates the
   278    `NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
   279    `NetworkSettings.IPPrefixLen`, and `NetworkSettings.MacAddress` fields, which
   280    are still returned for backward-compatibility, but will be removed in a future version.
   281  * `GET /exec/(id)/json` now returns a `NetworkSettings.Networks` field,
   282    detailing networksettings per network. This field deprecates the
   283    `NetworkSettings.Gateway`, `NetworkSettings.IPAddress`,
   284    `NetworkSettings.IPPrefixLen`, and `NetworkSettings.MacAddress` fields, which
   285    are still returned for backward-compatibility, but will be removed in a future version.
   286  * The `HostConfig` option now includes the `OomScoreAdj` field for adjusting the
   287    badness heuristic. This heuristic selects which processes the OOM killer kills
   288    under out-of-memory conditions.
   289  
   290  ### v1.20 API changes
   291  
   292  [Docker Remote API v1.20](docker_remote_api_v1.20.md) documentation
   293  
   294  * `GET /containers/(id)/archive` get an archive of filesystem content from a container.
   295  * `PUT /containers/(id)/archive` upload an archive of content to be extracted to
   296  an existing directory inside a container's filesystem.
   297  * `POST /containers/(id)/copy` is deprecated in favor of the above `archive`
   298  endpoint which can be used to download files and directories from a container.
   299  * The `hostConfig` option now accepts the field `GroupAdd`, which specifies a
   300  list of additional groups that the container process will run as.
   301  
   302  ### v1.19 API changes
   303  
   304  [Docker Remote API v1.19](docker_remote_api_v1.19.md) documentation
   305  
   306  * When the daemon detects a version mismatch with the client, usually when
   307  the client is newer than the daemon, an HTTP 400 is now returned instead
   308  of a 404.
   309  * `GET /containers/(id)/stats` now accepts `stream` bool to get only one set of stats and disconnect.
   310  * `GET /containers/(id)/logs` now accepts a `since` timestamp parameter.
   311  * `GET /info` The fields `Debug`, `IPv4Forwarding`, `MemoryLimit`, and
   312  `SwapLimit` are now returned as boolean instead of as an int. In addition, the
   313  end point now returns the new boolean fields `CpuCfsPeriod`, `CpuCfsQuota`, and
   314  `OomKillDisable`.
   315  * The `hostConfig` option now accepts the fields `CpuPeriod` and `CpuQuota`
   316  * `POST /build` accepts `cpuperiod` and `cpuquota` options
   317  
   318  ### v1.18 API changes
   319  
   320  [Docker Remote API v1.18](docker_remote_api_v1.18.md) documentation
   321  
   322  * `GET /version` now returns `Os`, `Arch` and `KernelVersion`.
   323  * `POST /containers/create` and `POST /containers/(id)/start`allow you to  set ulimit settings for use in the container.
   324  * `GET /info` now returns `SystemTime`, `HttpProxy`,`HttpsProxy` and `NoProxy`.
   325  * `GET /images/json` added a `RepoDigests` field to include image digest information.
   326  * `POST /build` can now set resource constraints for all containers created for the build.
   327  * `CgroupParent` can be passed in the host config to setup container cgroups under a specific cgroup.
   328  * `POST /build` closing the HTTP request cancels the build
   329  * `POST /containers/(id)/exec` includes `Warnings` field to response.