github.com/feiyang21687/docker@v1.5.0/docs/sources/reference/api/docker_remote_api.md (about)

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