github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/docs/reference/api/docker_remote_api.md (about)

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