github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/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 = "smn_remoteapi"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # Docker Remote API
    12  
    13   - By default the Docker daemon listens on `unix:///var/run/docker.sock`
    14     and the client must have `root` access to interact with the daemon.
    15   - If the Docker daemon is set to use an encrypted TCP socket (`--tls`,
    16     or `--tlsverify`) as with Boot2Docker 1.3.0, then you need to add extra
    17     parameters to `curl` or `wget` when making test API requests:
    18     `curl --insecure --cert ~/.docker/cert.pem --key ~/.docker/key.pem https://boot2docker:2376/images/json`
    19     or 
    20     `wget --no-check-certificate --certificate=$DOCKER_CERT_PATH/cert.pem --private-key=$DOCKER_CERT_PATH/key.pem https://boot2docker:2376/images/json -O - -q`
    21   - If a group named `docker` exists on your system, docker will apply
    22     ownership of the socket to the group.
    23   - The API tends to be REST, but for some complex commands, like attach
    24     or pull, the HTTP connection is hijacked to transport STDOUT, STDIN,
    25     and STDERR.
    26   - Since API version 1.2, the auth configuration is now handled client
    27     side, so the client has to send the `authConfig` as a `POST` in `/images/(name)/push`.
    28   - authConfig, set as the `X-Registry-Auth` header, is currently a Base64
    29     encoded (JSON) string with the following structure:
    30     `{"username": "string", "password": "string", "email": "string",
    31     "serveraddress" : "string", "auth": ""}`. Notice that `auth` is to be left
    32     empty, `serveraddress` is a domain/ip without protocol, and that double
    33     quotes (instead of single ones) are required.
    34   - The Remote API uses an open schema model.  In this model, unknown 
    35     properties in incoming messages will be ignored.
    36     Client applications need to take this into account to ensure
    37     they will not break when talking to newer Docker daemons.
    38  
    39  The current version of the API is v1.20
    40  
    41  Calling `/info` is the same as calling
    42  `/v1.20/info`.
    43  
    44  You can still call an old version of the API using
    45  `/v1.19/info`.
    46  
    47  ## Docker Events
    48  
    49  The following diagram depicts the container states accessible through the API.
    50  
    51  ![States](../images/event_state.png)
    52  
    53  Some container-related events are not affected by container state, so they are not included in this diagram. These events are:
    54  
    55  * **export** emitted by `docker export`
    56  * **exec_create** emitted by `docker exec`
    57  * **exec_start** emitted by `docker exec` after **exec_create**
    58  
    59  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.
    60  
    61  > **Acknowledgement**: 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](http://gliderlabs.com/blog/2015/04/14/docker-events-explained/).
    62  
    63  ## v1.20
    64  
    65  ### Full documentation
    66  
    67  [*Docker Remote API v1.20*](/reference/api/docker_remote_api_v1.20/)
    68  
    69  ### What's new
    70  
    71  ## v1.19
    72  
    73  ### Full documentation
    74  
    75  [*Docker Remote API v1.19*](/reference/api/docker_remote_api_v1.19/)
    76  
    77  ### What's new
    78  
    79  **New!**
    80  When the daemon detects a version mismatch with the client, usually when
    81  the client is newer than the daemon, an HTTP 400 is now returned instead
    82  of a 404.
    83  
    84  `GET /containers/(id)/stats`
    85  
    86  **New!**
    87  You can now supply a `stream` bool to get only one set of stats and
    88  disconnect
    89  
    90  `GET /containers(id)/logs`
    91  
    92  **New!**
    93  
    94  This endpoint now accepts a `since` timestamp parameter.
    95  
    96  `GET /info`
    97  
    98  **New!**
    99  
   100  The fields `Debug`, `IPv4Forwarding`, `MemoryLimit`, and `SwapLimit`
   101  are now returned as boolean instead of as an int.
   102  
   103  In addition, the end point now returns the new boolean fields
   104  `CpuCfsPeriod`, `CpuCfsQuota`, and `OomKillDisable`.
   105  
   106  ## v1.18
   107  
   108  ### Full documentation
   109  
   110  [*Docker Remote API v1.18*](/reference/api/docker_remote_api_v1.18/)
   111  
   112  ### What's new
   113  
   114  `GET /version`
   115  
   116  **New!**
   117  This endpoint now returns `Os`, `Arch` and `KernelVersion`.
   118  
   119  `POST /containers/create`
   120  `POST /containers/(id)/start`
   121  
   122  **New!**
   123  You can set ulimit settings to be used within the container.
   124  
   125  `GET /info`
   126  
   127  **New!**
   128  This endpoint now returns `SystemTime`, `HttpProxy`,`HttpsProxy` and `NoProxy`.
   129  
   130  `GET /images/json`
   131  
   132  **New!**
   133  Added a `RepoDigests` field to include image digest information.
   134  
   135  `POST /build`
   136  
   137  **New!**
   138  Builds can now set resource constraints for all containers created for the build.
   139  
   140  **New!**
   141  (`CgroupParent`) can be passed in the host config to setup container cgroups under a specific cgroup.
   142  
   143  `POST /build`
   144  
   145  **New!**
   146  Closing the HTTP request will now cause the build to be canceled.
   147  
   148  `POST /containers/(id)/exec`
   149  
   150  **New!**
   151  Add `Warnings` field to response.
   152  
   153  ## v1.17
   154  
   155  ### Full documentation
   156  
   157  [*Docker Remote API v1.17*](/reference/api/docker_remote_api_v1.17/)
   158  
   159  ### What's new
   160  
   161  The build supports `LABEL` command. Use this to add metadata
   162  to an image. For example you could add data describing the content of an image.
   163  
   164  `LABEL "com.example.vendor"="ACME Incorporated"`
   165  
   166  **New!**
   167  `POST /containers/(id)/attach` and `POST /exec/(id)/start`
   168  
   169  **New!**
   170  Docker client now hints potential proxies about connection hijacking using HTTP Upgrade headers.
   171  
   172  `POST /containers/create`
   173  
   174  **New!**
   175  You can set labels on container create describing the container.
   176  
   177  `GET /containers/json`
   178  
   179  **New!**
   180  The endpoint returns the labels associated with the containers (`Labels`).
   181  
   182  `GET /containers/(id)/json`
   183  
   184  **New!**
   185  This endpoint now returns the list current execs associated with the container (`ExecIDs`).
   186  This endpoint now returns the container labels (`Config.Labels`).
   187  
   188  `POST /containers/(id)/rename`
   189  
   190  **New!**
   191  New endpoint to rename a container `id` to a new name.
   192  
   193  `POST /containers/create`
   194  `POST /containers/(id)/start`
   195  
   196  **New!**
   197  (`ReadonlyRootfs`) can be passed in the host config to mount the container's
   198  root filesystem as read only.
   199  
   200  `GET /containers/(id)/stats`
   201  
   202  **New!**
   203  This endpoint returns a live stream of a container's resource usage statistics.
   204  
   205  `GET /images/json`
   206  
   207  **New!**
   208  This endpoint now returns the labels associated with each image (`Labels`).
   209  
   210  
   211  ## v1.16
   212  
   213  ### Full documentation
   214  
   215  [*Docker Remote API v1.16*](/reference/api/docker_remote_api_v1.16/)
   216  
   217  ### What's new
   218  
   219  `GET /info`
   220  
   221  **New!**
   222  `info` now returns the number of CPUs available on the machine (`NCPU`),
   223  total memory available (`MemTotal`), a user-friendly name describing the running Docker daemon (`Name`), a unique ID identifying the daemon (`ID`), and
   224  a list of daemon labels (`Labels`).
   225  
   226  `POST /containers/create`
   227  
   228  **New!**
   229  You can set the new container's MAC address explicitly.
   230  
   231  **New!**
   232  Volumes are now initialized when the container is created.
   233  
   234  `POST /containers/(id)/copy`
   235  
   236  **New!**
   237  You can now copy data which is contained in a volume.
   238  
   239  ## v1.15
   240  
   241  ### Full documentation
   242  
   243  [*Docker Remote API v1.15*](/reference/api/docker_remote_api_v1.15/)
   244  
   245  ### What's new
   246  
   247  `POST /containers/create`
   248  
   249  **New!**
   250  It is now possible to set a container's HostConfig when creating a container.
   251  Previously this was only available when starting a container.
   252  
   253  ## v1.14
   254  
   255  ### Full documentation
   256  
   257  [*Docker Remote API v1.14*](/reference/api/docker_remote_api_v1.14/)
   258  
   259  ### What's new
   260  
   261  `DELETE /containers/(id)`
   262  
   263  **New!**
   264  When using `force`, the container will be immediately killed with SIGKILL.
   265  
   266  `POST /containers/(id)/start`
   267  
   268  **New!**
   269  The `hostConfig` option now accepts the field `CapAdd`, which specifies a list of capabilities
   270  to add, and the field `CapDrop`, which specifies a list of capabilities to drop.
   271  
   272  `POST /images/create`
   273  
   274  **New!**
   275  The `fromImage` and `repo` parameters now supports the `repo:tag` format.
   276  Consequently,  the `tag` parameter is now obsolete. Using the new format and
   277  the `tag` parameter at the same time will return an error.
   278  
   279  ## v1.13
   280  
   281  ### Full documentation
   282  
   283  [*Docker Remote API v1.13*](/reference/api/docker_remote_api_v1.13/)
   284  
   285  ### What's new
   286  
   287  `GET /containers/(name)/json`
   288  
   289  **New!**
   290  The `HostConfig.Links` field is now filled correctly
   291  
   292  **New!**
   293  `Sockets` parameter added to the `/info` endpoint listing all the sockets the 
   294  daemon is configured to listen on.
   295  
   296  `POST /containers/(name)/start`
   297  `POST /containers/(name)/stop`
   298  
   299  **New!**
   300  `start` and `stop` will now return 304 if the container's status is not modified
   301  
   302  `POST /commit`
   303  
   304  **New!**
   305  Added a `pause` parameter (default `true`) to pause the container during commit
   306  
   307  ## v1.12
   308  
   309  ### Full documentation
   310  
   311  [*Docker Remote API v1.12*](/reference/api/docker_remote_api_v1.12/)
   312  
   313  ### What's new
   314  
   315  `POST /build`
   316  
   317  **New!**
   318  Build now has support for the `forcerm` parameter to always remove containers
   319  
   320  `GET /containers/(name)/json`
   321  `GET /images/(name)/json`
   322  
   323  **New!**
   324  All the JSON keys are now in CamelCase
   325  
   326  **New!**
   327  Trusted builds are now Automated Builds - `is_trusted` is now `is_automated`.
   328  
   329  **Removed Insert Endpoint**
   330  The `insert` endpoint has been removed.
   331  
   332  ## v1.11
   333  
   334  ### Full documentation
   335  
   336  [*Docker Remote API v1.11*](/reference/api/docker_remote_api_v1.11/)
   337  
   338  ### What's new
   339  
   340  `GET /_ping`
   341  
   342  **New!**
   343  You can now ping the server via the `_ping` endpoint.
   344  
   345  `GET /events`
   346  
   347  **New!**
   348  You can now use the `-until` parameter to close connection
   349  after timestamp.
   350  
   351  `GET /containers/(id)/logs`
   352  
   353  This url is preferred method for getting container logs now.
   354  
   355  ## v1.10
   356  
   357  ### Full documentation
   358  
   359  [*Docker Remote API v1.10*](/reference/api/docker_remote_api_v1.10/)
   360  
   361  ### What's new
   362  
   363  `DELETE /images/(name)`
   364  
   365  **New!**
   366  You can now use the force parameter to force delete of an
   367      image, even if it's tagged in multiple repositories. **New!**
   368      You
   369      can now use the noprune parameter to prevent the deletion of parent
   370      images
   371  
   372  `DELETE /containers/(id)`
   373  
   374  **New!**
   375  You can now use the force parameter to force delete a
   376      container, even if it is currently running
   377  
   378  ## v1.9
   379  
   380  ### Full documentation
   381  
   382  [*Docker Remote API v1.9*](/reference/api/docker_remote_api_v1.9/)
   383  
   384  ### What's new
   385  
   386  `POST /build`
   387  
   388  **New!**
   389  This endpoint now takes a serialized ConfigFile which it
   390  uses to resolve the proper registry auth credentials for pulling the
   391  base image. Clients which previously implemented the version
   392  accepting an AuthConfig object must be updated.
   393  
   394  ## v1.8
   395  
   396  ### Full documentation
   397  
   398  [*Docker Remote API v1.8*](/reference/api/docker_remote_api_v1.8/)
   399  
   400  ### What's new
   401  
   402  `POST /build`
   403  
   404  **New!**
   405  This endpoint now returns build status as json stream. In
   406  case of a build error, it returns the exit status of the failed
   407  command.
   408  
   409  `GET /containers/(id)/json`
   410  
   411  **New!**
   412  This endpoint now returns the host config for the
   413  container.
   414  
   415  `POST /images/create`
   416  
   417  `POST /images/(name)/insert`
   418  
   419  `POST /images/(name)/push`
   420  
   421  **New!**
   422  progressDetail object was added in the JSON. It's now
   423  possible to get the current value and the total of the progress
   424  without having to parse the string.
   425  
   426  ## v1.7
   427  
   428  ### Full documentation
   429  
   430  [*Docker Remote API v1.7*](/reference/api/docker_remote_api_v1.7/)
   431  
   432  ### What's new
   433  
   434  `GET /images/json`
   435  
   436  The format of the json returned from this uri changed. Instead of an
   437  entry for each repo/tag on an image, each image is only represented
   438  once, with a nested attribute indicating the repo/tags that apply to
   439  that image.
   440  
   441  Instead of:
   442  
   443      HTTP/1.1 200 OK
   444      Content-Type: application/json
   445  
   446      [
   447        {
   448          "VirtualSize": 131506275,
   449          "Size": 131506275,
   450          "Created": 1365714795,
   451          "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   452          "Tag": "12.04",
   453          "Repository": "ubuntu"
   454        },
   455        {
   456          "VirtualSize": 131506275,
   457          "Size": 131506275,
   458          "Created": 1365714795,
   459          "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   460          "Tag": "latest",
   461          "Repository": "ubuntu"
   462        },
   463        {
   464          "VirtualSize": 131506275,
   465          "Size": 131506275,
   466          "Created": 1365714795,
   467          "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   468          "Tag": "precise",
   469          "Repository": "ubuntu"
   470        },
   471        {
   472          "VirtualSize": 180116135,
   473          "Size": 24653,
   474          "Created": 1364102658,
   475          "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   476          "Tag": "12.10",
   477          "Repository": "ubuntu"
   478        },
   479        {
   480          "VirtualSize": 180116135,
   481          "Size": 24653,
   482          "Created": 1364102658,
   483          "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   484          "Tag": "quantal",
   485          "Repository": "ubuntu"
   486        }
   487      ]
   488  
   489  The returned json looks like this:
   490  
   491      HTTP/1.1 200 OK
   492      Content-Type: application/json
   493  
   494      [
   495        {
   496           "RepoTags": [
   497             "ubuntu:12.04",
   498             "ubuntu:precise",
   499             "ubuntu:latest"
   500           ],
   501           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   502           "Created": 1365714795,
   503           "Size": 131506275,
   504           "VirtualSize": 131506275
   505        },
   506        {
   507           "RepoTags": [
   508             "ubuntu:12.10",
   509             "ubuntu:quantal"
   510           ],
   511           "ParentId": "27cf784147099545",
   512           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   513           "Created": 1364102658,
   514           "Size": 24653,
   515           "VirtualSize": 180116135
   516        }
   517      ]
   518  
   519  `GET /images/viz`
   520  
   521  This URI no longer exists. The `images --viz`
   522  output is now generated in the client, using the
   523  `/images/json` data.
   524  
   525  ## v1.6
   526  
   527  ### Full documentation
   528  
   529  [*Docker Remote API v1.6*](/reference/api/docker_remote_api_v1.6/)
   530  
   531  ### What's new
   532  
   533  `POST /containers/(id)/attach`
   534  
   535  **New!**
   536  You can now split stderr from stdout. This is done by
   537  prefixing a header to each transmission. See
   538  [`POST /containers/(id)/attach`](
   539  /reference/api/docker_remote_api_v1.9/#attach-to-a-container "POST /containers/(id)/attach").
   540  The WebSocket attach is unchanged. Note that attach calls on the
   541  previous API version didn't change. Stdout and stderr are merged.
   542  
   543  ## v1.5
   544  
   545  ### Full documentation
   546  
   547  [*Docker Remote API v1.5*](/reference/api/docker_remote_api_v1.5/)
   548  
   549  ### What's new
   550  
   551  `POST /images/create`
   552  
   553  **New!**
   554  You can now pass registry credentials (via an AuthConfig
   555      object) through the X-Registry-Auth header
   556  
   557  `POST /images/(name)/push`
   558  
   559  **New!**
   560  The AuthConfig object now needs to be passed through the
   561      X-Registry-Auth header
   562  
   563  `GET /containers/json`
   564  
   565  **New!**
   566  The format of the Ports entry has been changed to a list of
   567  dicts each containing PublicPort, PrivatePort and Type describing a
   568  port mapping.
   569  
   570  ## v1.4
   571  
   572  ### Full documentation
   573  
   574  [*Docker Remote API v1.4*](/reference/api/docker_remote_api_v1.4/)
   575  
   576  ### What's new
   577  
   578  `POST /images/create`
   579  
   580  **New!**
   581  When pulling a repo, all images are now downloaded in parallel.
   582  
   583  `GET /containers/(id)/top`
   584  
   585  **New!**
   586  You can now use ps args with docker top, like docker top
   587      <container_id> aux
   588  
   589  `GET /events`
   590  
   591  **New!**
   592  Image's name added in the events
   593  
   594  ## v1.3
   595  
   596  docker v0.5.0
   597  [51f6c4a](https://github.com/docker/docker/commit/51f6c4a7372450d164c61e0054daf0223ddbd909)
   598  
   599  ### Full documentation
   600  
   601  [*Docker Remote API v1.3*](/reference/api/docker_remote_api_v1.3/)
   602  
   603  ### What's new
   604  
   605  `GET /containers/(id)/top`
   606  
   607  List the processes running inside a container.
   608  
   609  `GET /events`
   610  
   611  **New!**
   612  Monitor docker's events via streaming or via polling
   613  
   614  Builder (/build):
   615  
   616   - Simplify the upload of the build context
   617   - Simply stream a tarball instead of multipart upload with 4
   618     intermediary buffers
   619   - Simpler, less memory usage, less disk usage and faster
   620  
   621  > **Warning**: 
   622  > The /build improvements are not reverse-compatible. Pre 1.3 clients will
   623  > break on /build.
   624  
   625  List containers (/containers/json):
   626  
   627   - You can use size=1 to get the size of the containers
   628  
   629  Start containers (/containers/<id>/start):
   630  
   631   - You can now pass host-specific configuration (e.g., bind mounts) in
   632     the POST body for start calls
   633  
   634  ## v1.2
   635  
   636  docker v0.4.2
   637  [2e7649b](https://github.com/docker/docker/commit/2e7649beda7c820793bd46766cbc2cfeace7b168)
   638  
   639  ### Full documentation
   640  
   641  [*Docker Remote API v1.2*](/reference/api/docker_remote_api_v1.2/)
   642  
   643  ### What's new
   644  
   645  The auth configuration is now handled by the client.
   646  
   647  The client should send it's authConfig as POST on each call of
   648  `/images/(name)/push`
   649  
   650  `GET /auth`
   651  
   652  **Deprecated.**
   653  
   654  `POST /auth`
   655  
   656  Only checks the configuration but doesn't store it on the server
   657  
   658      Deleting an image is now improved, will only untag the image if it
   659      has children and remove all the untagged parents if has any.
   660  
   661  `POST /images/<name>/delete`
   662  
   663  Now returns a JSON structure with the list of images
   664  deleted/untagged.
   665  
   666  ## v1.1
   667  
   668  docker v0.4.0
   669  [a8ae398](https://github.com/docker/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f)
   670  
   671  ### Full documentation
   672  
   673  [*Docker Remote API v1.1*](/reference/api/docker_remote_api_v1.1/)
   674  
   675  ### What's new
   676  
   677  `POST /images/create`
   678  
   679  `POST /images/(name)/insert`
   680  
   681  `POST /images/(name)/push`
   682  
   683  Uses json stream instead of HTML hijack, it looks like this:
   684  
   685          HTTP/1.1 200 OK
   686          Content-Type: application/json
   687  
   688          {"status":"Pushing..."}
   689          {"status":"Pushing", "progress":"1/? (n/a)"}
   690          {"error":"Invalid..."}
   691          ...
   692  
   693  ## v1.0
   694  
   695  docker v0.3.4
   696  [8d73740](https://github.com/docker/docker/commit/8d73740343778651c09160cde9661f5f387b36f4)
   697  
   698  ### Full documentation
   699  
   700  [*Docker Remote API v1.0*](/reference/api/docker_remote_api_v1.0/)
   701  
   702  ### What's new
   703  
   704  Initial version