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