github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/docs/reference/api/docker_remote_api_v1.16.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.16"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent = "smn_remoteapi"
     8  weight = 5
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.16
    13  
    14  ## 1. Brief introduction
    15  
    16   - The Remote API has replaced `rcli`.
    17   - The daemon listens on `unix:///var/run/docker.sock` but you can
    18     [Bind Docker to another host/port or a Unix socket](
    19     /articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
    20   - The API tends to be REST, but for some complex commands, like `attach`
    21     or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
    22     `STDIN` and `STDERR`.
    23  
    24  # 2. Endpoints
    25  
    26  ## 2.1 Containers
    27  
    28  ### List containers
    29  
    30  `GET /containers/json`
    31  
    32  List containers
    33  
    34  **Example request**:
    35  
    36          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    37  
    38  **Example response**:
    39  
    40          HTTP/1.1 200 OK
    41          Content-Type: application/json
    42  
    43          [
    44               {
    45                       "Id": "8dfafdbc3a40",
    46                       "Image": "ubuntu:latest",
    47                       "Command": "echo 1",
    48                       "Created": 1367854155,
    49                       "Status": "Exit 0",
    50                       "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    51                       "SizeRw": 12288,
    52                       "SizeRootFs": 0
    53               },
    54               {
    55                       "Id": "9cd87474be90",
    56                       "Image": "ubuntu:latest",
    57                       "Command": "echo 222222",
    58                       "Created": 1367854155,
    59                       "Status": "Exit 0",
    60                       "Ports": [],
    61                       "SizeRw": 12288,
    62                       "SizeRootFs": 0
    63               },
    64               {
    65                       "Id": "3176a2479c92",
    66                       "Image": "ubuntu:latest",
    67                       "Command": "echo 3333333333333333",
    68                       "Created": 1367854154,
    69                       "Status": "Exit 0",
    70                       "Ports":[],
    71                       "SizeRw":12288,
    72                       "SizeRootFs":0
    73               },
    74               {
    75                       "Id": "4cb07b47f9fb",
    76                       "Image": "ubuntu:latest",
    77                       "Command": "echo 444444444444444444444444444444444",
    78                       "Created": 1367854152,
    79                       "Status": "Exit 0",
    80                       "Ports": [],
    81                       "SizeRw": 12288,
    82                       "SizeRootFs": 0
    83               }
    84          ]
    85  
    86  Query Parameters:
    87  
    88  -   **all** – 1/True/true or 0/False/false, Show all containers.
    89          Only running containers are shown by default (i.e., this defaults to false)
    90  -   **limit** – Show `limit` last created
    91          containers, include non-running ones.
    92  -   **since** – Show only containers created since Id, include
    93          non-running ones.
    94  -   **before** – Show only containers created before Id, include
    95          non-running ones.
    96  -   **size** – 1/True/true or 0/False/false, Show the containers
    97          sizes
    98  -   **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
    99    -   exited=&lt;int&gt; -- containers with exit code of &lt;int&gt;
   100    -   status=(restarting|running|paused|exited)
   101  
   102  Status Codes:
   103  
   104  -   **200** – no error
   105  -   **400** – bad parameter
   106  -   **500** – server error
   107  
   108  ### Create a container
   109  
   110  `POST /containers/create`
   111  
   112  Create a container
   113  
   114  **Example request**:
   115  
   116          POST /containers/create HTTP/1.1
   117          Content-Type: application/json
   118  
   119          {
   120               "Hostname": "",
   121               "Domainname": "",
   122               "User": "",
   123               "Memory": 0,
   124               "MemorySwap": 0,
   125               "CpuShares": 512,
   126               "Cpuset": "0,1",
   127               "AttachStdin": false,
   128               "AttachStdout": true,
   129               "AttachStderr": true,
   130               "Tty": false,
   131               "OpenStdin": false,
   132               "StdinOnce": false,
   133               "Env": null,
   134               "Cmd": [
   135                       "date"
   136               ],
   137               "Entrypoint": "",
   138               "Image": "ubuntu",
   139               "Volumes": {
   140                       "/tmp": {}
   141               },
   142               "WorkingDir": "",
   143               "NetworkDisabled": false,
   144               "MacAddress": "12:34:56:78:9a:bc",
   145               "ExposedPorts": {
   146                       "22/tcp": {}
   147               },
   148               "SecurityOpts": [""],
   149               "HostConfig": {
   150                 "Binds": ["/tmp:/tmp"],
   151                 "Links": ["redis3:redis"],
   152                 "LxcConf": {"lxc.utsname":"docker"},
   153                 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   154                 "PublishAllPorts": false,
   155                 "Privileged": false,
   156                 "Dns": ["8.8.8.8"],
   157                 "DnsSearch": [""],
   158                 "ExtraHosts": null,
   159                 "VolumesFrom": ["parent", "other:ro"],
   160                 "CapAdd": ["NET_ADMIN"],
   161                 "CapDrop": ["MKNOD"],
   162                 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   163                 "NetworkMode": "bridge",
   164                 "Devices": []
   165              }
   166          }
   167  
   168  **Example response**:
   169  
   170          HTTP/1.1 201 Created
   171          Content-Type: application/json
   172  
   173          {
   174               "Id":"e90e34656806"
   175               "Warnings":[]
   176          }
   177  
   178  Json Parameters:
   179  
   180  -   **Hostname** - A string value containing the desired hostname to use for the
   181        container.
   182  -   **Domainname** - A string value containing the desired domain name to use
   183        for the container.
   184  -   **User** - A string value containing the user to use inside the container.
   185  -   **Memory** - Memory limit in bytes.
   186  -   **MemorySwap**- Total memory usage (memory + swap); set `-1` to disable swap.
   187  -   **CpuShares** - An integer value containing the CPU Shares for container
   188        (ie. the relative weight vs other containers).
   189      **CpuSet** - String value containing the cgroups Cpuset to use.
   190  -   **AttachStdin** - Boolean value, attaches to stdin.
   191  -   **AttachStdout** - Boolean value, attaches to stdout.
   192  -   **AttachStderr** - Boolean value, attaches to stderr.
   193  -   **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
   194  -   **OpenStdin** - Boolean value, opens stdin,
   195  -   **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects.
   196  -   **Env** - A list of environment variables in the form of `VAR=value`
   197  -   **Cmd** - Command to run specified as a string or an array of strings.
   198  -   **Entrypoint** - Set the entrypoint for the container a string or an array
   199        of strings
   200  -   **Image** - String value containing the image name to use for the container
   201  -   **Volumes** – An object mapping mountpoint paths (strings) inside the
   202          container to empty objects.
   203  -   **WorkingDir** - A string value containing the working dir for commands to
   204        run in.
   205  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   206        container
   207  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   208        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   209  -   **SecurityOpts**: A list of string values to customize labels for MLS
   210        systems, such as SELinux.
   211  -   **HostConfig**
   212    -   **Binds** – A list of volume bindings for this container.  Each volume
   213            binding is a string of the form `container_path` (to create a new
   214            volume for the container), `host_path:container_path` (to bind-mount
   215            a host path into the container), or `host_path:container_path:ro`
   216            (to make the bind-mount read-only inside the container).
   217    -   **Links** - A list of links for the container.  Each link entry should be
   218          in the form of "container_name:alias".
   219    -   **LxcConf** - LXC specific configurations.  These configurations will only
   220          work when using the `lxc` execution driver.
   221    -   **PortBindings** - A map of exposed container ports and the host port they
   222          should map to. It should be specified in the form
   223          `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   224          Take note that `port` is specified as a string and not an integer value.
   225    -   **PublishAllPorts** - Allocates a random host port for all of a container's
   226          exposed ports. Specified as a boolean value.
   227    -   **Privileged** - Gives the container full access to the host.  Specified as
   228          a boolean value.
   229    -   **Dns** - A list of dns servers for the container to use.
   230    -   **DnsSearch** - A list of DNS search domains
   231    -   **ExtraHosts** - A list of hostnames/IP mappings to be added to the
   232        container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   233    -   **VolumesFrom** - A list of volumes to inherit from another container.
   234          Specified in the form `<container name>[:<ro|rw>]`
   235    -   **CapAdd** - A list of kernel capabilities to add to the container.
   236    -   **Capdrop** - A list of kernel capabilities to drop from the container.
   237    -   **RestartPolicy** – The behavior to apply when the container exits.  The
   238            value is an object with a `Name` property of either `"always"` to
   239            always restart or `"on-failure"` to restart only when the container
   240            exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   241            controls the number of times to retry before giving up.
   242            The default is not to restart. (optional)
   243            An ever increasing delay (double the previous delay, starting at 100mS)
   244            is added before each restart to prevent flooding the server.
   245    -   **NetworkMode** - Sets the networking mode for the container. Supported
   246          values are: `bridge`, `host`, and `container:<name|id>`
   247    -   **Devices** - A list of devices to add to the container specified in the
   248          form
   249          `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   250  
   251  Query Parameters:
   252  
   253  -   **name** – Assign the specified name to the container. Must
   254      match `/?[a-zA-Z0-9_-]+`.
   255  
   256  Status Codes:
   257  
   258  -   **201** – no error
   259  -   **404** – no such container
   260  -   **406** – impossible to attach (container not running)
   261  -   **500** – server error
   262  
   263  ### Inspect a container
   264  
   265  `GET /containers/(id)/json`
   266  
   267  Return low-level information on the container `id`
   268  
   269  
   270  **Example request**:
   271  
   272          GET /containers/4fa6e0f0c678/json HTTP/1.1
   273  
   274  **Example response**:
   275  
   276          HTTP/1.1 200 OK
   277          Content-Type: application/json
   278  
   279          {
   280                       "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
   281                       "Created": "2013-05-07T14:51:42.041847+02:00",
   282                       "Path": "date",
   283                       "Args": [],
   284                       "Config": {
   285                               "Hostname": "4fa6e0f0c678",
   286                               "User": "",
   287                               "Memory": 0,
   288                               "MemorySwap": 0,
   289                               "AttachStdin": false,
   290                               "AttachStdout": true,
   291                               "AttachStderr": true,
   292                               "PortSpecs": null,
   293                               "Tty": false,
   294                               "OpenStdin": false,
   295                               "StdinOnce": false,
   296                               "Env": null,
   297                               "Cmd": [
   298                                       "date"
   299                               ],
   300                               "Dns": null,
   301                               "Image": "ubuntu",
   302                               "Volumes": {},
   303                               "VolumesFrom": "",
   304                               "WorkingDir": ""
   305                       },
   306                       "State": {
   307                               "Running": false,
   308                               "Pid": 0,
   309                               "ExitCode": 0,
   310                               "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
   311                               "Ghost": false
   312                       },
   313                       "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   314                       "NetworkSettings": {
   315                               "IpAddress": "",
   316                               "IpPrefixLen": 0,
   317                               "Gateway": "",
   318                               "Bridge": "",
   319                               "PortMapping": null
   320                       },
   321                       "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker",
   322                       "ResolvConfPath": "/etc/resolv.conf",
   323                       "Volumes": {},
   324                       "HostConfig": {
   325                           "Binds": null,
   326                           "ContainerIDFile": "",
   327                           "LxcConf": [],
   328                           "Privileged": false,
   329                           "PortBindings": {
   330                              "80/tcp": [
   331                                  {
   332                                      "HostIp": "0.0.0.0",
   333                                      "HostPort": "49153"
   334                                  }
   335                              ]
   336                           },
   337                           "Links": ["/name:alias"],
   338                           "PublishAllPorts": false,
   339                           "CapAdd": ["NET_ADMIN"],
   340                           "CapDrop": ["MKNOD"]
   341                       }
   342          }
   343  
   344  Status Codes:
   345  
   346  -   **200** – no error
   347  -   **404** – no such container
   348  -   **500** – server error
   349  
   350  ### List processes running inside a container
   351  
   352  `GET /containers/(id)/top`
   353  
   354  List processes running inside the container `id`
   355  
   356  **Example request**:
   357  
   358          GET /containers/4fa6e0f0c678/top HTTP/1.1
   359  
   360  **Example response**:
   361  
   362          HTTP/1.1 200 OK
   363          Content-Type: application/json
   364  
   365          {
   366               "Titles": [
   367                       "USER",
   368                       "PID",
   369                       "%CPU",
   370                       "%MEM",
   371                       "VSZ",
   372                       "RSS",
   373                       "TTY",
   374                       "STAT",
   375                       "START",
   376                       "TIME",
   377                       "COMMAND"
   378                       ],
   379               "Processes": [
   380                       ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   381                       ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   382               ]
   383          }
   384  
   385  Query Parameters:
   386  
   387  -   **ps_args** – ps arguments to use (e.g., aux)
   388  
   389  Status Codes:
   390  
   391  -   **200** – no error
   392  -   **404** – no such container
   393  -   **500** – server error
   394  
   395  ### Get container logs
   396  
   397  `GET /containers/(id)/logs`
   398  
   399  Get stdout and stderr logs from the container ``id``
   400  
   401  **Example request**:
   402  
   403         GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10 HTTP/1.1
   404  
   405  **Example response**:
   406  
   407         HTTP/1.1 200 OK
   408         Content-Type: application/vnd.docker.raw-stream
   409  
   410         {{ STREAM }}
   411  
   412  Query Parameters:
   413  
   414  -   **follow** – 1/True/true or 0/False/false, return stream. Default false
   415  -   **stdout** – 1/True/true or 0/False/false, show stdout log. Default false
   416  -   **stderr** – 1/True/true or 0/False/false, show stderr log. Default false
   417  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   418          every log line. Default false
   419  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all
   420  
   421  Status Codes:
   422  
   423  -   **200** – no error
   424  -   **404** – no such container
   425  -   **500** – server error
   426  
   427  ### Inspect changes on a container's filesystem
   428  
   429  `GET /containers/(id)/changes`
   430  
   431  Inspect changes on container `id`'s filesystem
   432  
   433  **Example request**:
   434  
   435          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   436  
   437  **Example response**:
   438  
   439          HTTP/1.1 200 OK
   440          Content-Type: application/json
   441  
   442          [
   443               {
   444                       "Path": "/dev",
   445                       "Kind": 0
   446               },
   447               {
   448                       "Path": "/dev/kmsg",
   449                       "Kind": 1
   450               },
   451               {
   452                       "Path": "/test",
   453                       "Kind": 1
   454               }
   455          ]
   456  
   457  Status Codes:
   458  
   459  -   **200** – no error
   460  -   **404** – no such container
   461  -   **500** – server error
   462  
   463  ### Export a container
   464  
   465  `GET /containers/(id)/export`
   466  
   467  Export the contents of container `id`
   468  
   469  **Example request**:
   470  
   471          GET /containers/4fa6e0f0c678/export HTTP/1.1
   472  
   473  **Example response**:
   474  
   475          HTTP/1.1 200 OK
   476          Content-Type: application/octet-stream
   477  
   478          {{ TAR STREAM }}
   479  
   480  Status Codes:
   481  
   482  -   **200** – no error
   483  -   **404** – no such container
   484  -   **500** – server error
   485  
   486  ### Resize a container TTY
   487  
   488  `POST /containers/(id)/resize?h=<height>&w=<width>`
   489  
   490  Resize the TTY for container with  `id`. The container must be restarted for the resize to take effect.
   491  
   492  **Example request**:
   493  
   494          POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   495  
   496  **Example response**:
   497  
   498          HTTP/1.1 200 OK
   499          Content-Length: 0
   500          Content-Type: text/plain; charset=utf-8
   501  
   502  Status Codes:
   503  
   504  -   **200** – no error
   505  -   **404** – No such container
   506  -   **500** – Cannot resize container
   507  
   508  ### Start a container
   509  
   510  `POST /containers/(id)/start`
   511  
   512  Start the container `id`
   513  
   514  > **Note**:
   515  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   516  > See [create a container](#create-a-container) for details.
   517  
   518  **Example request**:
   519  
   520          POST /containers/(id)/start HTTP/1.1
   521  
   522  **Example response**:
   523  
   524          HTTP/1.1 204 No Content
   525  
   526  Status Codes:
   527  
   528  -   **204** – no error
   529  -   **304** – container already started
   530  -   **404** – no such container
   531  -   **500** – server error
   532  
   533  ### Stop a container
   534  
   535  `POST /containers/(id)/stop`
   536  
   537  Stop the container `id`
   538  
   539  **Example request**:
   540  
   541          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   542  
   543  **Example response**:
   544  
   545          HTTP/1.1 204 No Content
   546  
   547  Query Parameters:
   548  
   549  -   **t** – number of seconds to wait before killing the container
   550  
   551  Status Codes:
   552  
   553  -   **204** – no error
   554  -   **304** – container already stopped
   555  -   **404** – no such container
   556  -   **500** – server error
   557  
   558  ### Restart a container
   559  
   560  `POST /containers/(id)/restart`
   561  
   562  Restart the container `id`
   563  
   564  **Example request**:
   565  
   566          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   567  
   568  **Example response**:
   569  
   570          HTTP/1.1 204 No Content
   571  
   572  Query Parameters:
   573  
   574  -   **t** – number of seconds to wait before killing the container
   575  
   576  Status Codes:
   577  
   578  -   **204** – no error
   579  -   **404** – no such container
   580  -   **500** – server error
   581  
   582  ### Kill a container
   583  
   584  `POST /containers/(id)/kill`
   585  
   586  Kill the container `id`
   587  
   588  **Example request**:
   589  
   590          POST /containers/e90e34656806/kill HTTP/1.1
   591  
   592  **Example response**:
   593  
   594          HTTP/1.1 204 No Content
   595  
   596  Query Parameters
   597  
   598  -   **signal** - Signal to send to the container: integer or string like "SIGINT".
   599          When not set, SIGKILL is assumed and the call will waits for the container to exit.
   600  
   601  Status Codes:
   602  
   603  -   **204** – no error
   604  -   **404** – no such container
   605  -   **500** – server error
   606  
   607  ### Pause a container
   608  
   609  `POST /containers/(id)/pause`
   610  
   611  Pause the container `id`
   612  
   613  **Example request**:
   614  
   615          POST /containers/e90e34656806/pause HTTP/1.1
   616  
   617  **Example response**:
   618  
   619          HTTP/1.1 204 No Content
   620  
   621  Status Codes:
   622  
   623  -   **204** – no error
   624  -   **404** – no such container
   625  -   **500** – server error
   626  
   627  ### Unpause a container
   628  
   629  `POST /containers/(id)/unpause`
   630  
   631  Unpause the container `id`
   632  
   633  **Example request**:
   634  
   635          POST /containers/e90e34656806/unpause HTTP/1.1
   636  
   637  **Example response**:
   638  
   639          HTTP/1.1 204 No Content
   640  
   641  Status Codes:
   642  
   643  -   **204** – no error
   644  -   **404** – no such container
   645  -   **500** – server error
   646  
   647  ### Attach to a container
   648  
   649  `POST /containers/(id)/attach`
   650  
   651  Attach to the container `id`
   652  
   653  **Example request**:
   654  
   655          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   656  
   657  **Example response**:
   658  
   659          HTTP/1.1 200 OK
   660          Content-Type: application/vnd.docker.raw-stream
   661  
   662          {{ STREAM }}
   663  
   664  Query Parameters:
   665  
   666  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   667  -   **stream** – 1/True/true or 0/False/false, return stream.
   668          Default false
   669  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   670          to stdin. Default false
   671  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   672          stdout log, if stream=true, attach to stdout. Default false
   673  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   674          stderr log, if stream=true, attach to stderr. Default false
   675  
   676  Status Codes:
   677  
   678  -   **200** – no error
   679  -   **400** – bad parameter
   680  -   **404** – no such container
   681  -   **500** – server error
   682  
   683      **Stream details**:
   684  
   685      When using the TTY setting is enabled in
   686      [`POST /containers/create`
   687      ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
   688      the stream is the raw data from the process PTY and client's stdin.
   689      When the TTY is disabled, then the stream is multiplexed to separate
   690      stdout and stderr.
   691  
   692      The format is a **Header** and a **Payload** (frame).
   693  
   694      **HEADER**
   695  
   696      The header will contain the information on which stream write the
   697      stream (stdout or stderr). It also contain the size of the
   698      associated frame encoded on the last 4 bytes (uint32).
   699  
   700      It is encoded on the first 8 bytes like this:
   701  
   702          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   703  
   704      `STREAM_TYPE` can be:
   705  
   706  -   0: stdin (will be written on stdout)
   707  -   1: stdout
   708  -   2: stderr
   709  
   710      `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
   711      the uint32 size encoded as big endian.
   712  
   713      **PAYLOAD**
   714  
   715      The payload is the raw stream.
   716  
   717      **IMPLEMENTATION**
   718  
   719      The simplest way to implement the Attach protocol is the following:
   720  
   721      1.  Read 8 bytes
   722      2.  chose stdout or stderr depending on the first byte
   723      3.  Extract the frame size from the last 4 bytes
   724      4.  Read the extracted size and output it on the correct output
   725      5.  Goto 1
   726  
   727  ### Attach to a container (websocket)
   728  
   729  `GET /containers/(id)/attach/ws`
   730  
   731  Attach to the container `id` via websocket
   732  
   733  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   734  
   735  **Example request**
   736  
   737          GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   738  
   739  **Example response**
   740  
   741          {{ STREAM }}
   742  
   743  Query Parameters:
   744  
   745  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   746  -   **stream** – 1/True/true or 0/False/false, return stream.
   747          Default false
   748  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   749          to stdin. Default false
   750  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   751          stdout log, if stream=true, attach to stdout. Default false
   752  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   753          stderr log, if stream=true, attach to stderr. Default false
   754  
   755  Status Codes:
   756  
   757  -   **200** – no error
   758  -   **400** – bad parameter
   759  -   **404** – no such container
   760  -   **500** – server error
   761  
   762  ### Wait a container
   763  
   764  `POST /containers/(id)/wait`
   765  
   766  Block until container `id` stops, then returns the exit code
   767  
   768  **Example request**:
   769  
   770          POST /containers/16253994b7c4/wait HTTP/1.1
   771  
   772  **Example response**:
   773  
   774          HTTP/1.1 200 OK
   775          Content-Type: application/json
   776  
   777          {"StatusCode": 0}
   778  
   779  Status Codes:
   780  
   781  -   **200** – no error
   782  -   **404** – no such container
   783  -   **500** – server error
   784  
   785  ### Remove a container
   786  
   787  `DELETE /containers/(id)`
   788  
   789  Remove the container `id` from the filesystem
   790  
   791  **Example request**:
   792  
   793          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   794  
   795  **Example response**:
   796  
   797          HTTP/1.1 204 No Content
   798  
   799  Query Parameters:
   800  
   801  -   **v** – 1/True/true or 0/False/false, Remove the volumes
   802          associated to the container. Default false
   803  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
   804          Default false
   805  
   806  Status Codes:
   807  
   808  -   **204** – no error
   809  -   **400** – bad parameter
   810  -   **404** – no such container
   811  -   **500** – server error
   812  
   813  ### Copy files or folders from a container
   814  
   815  `POST /containers/(id)/copy`
   816  
   817  Copy files or folders of container `id`
   818  
   819  **Example request**:
   820  
   821          POST /containers/4fa6e0f0c678/copy HTTP/1.1
   822          Content-Type: application/json
   823  
   824          {
   825               "Resource": "test.txt"
   826          }
   827  
   828  **Example response**:
   829  
   830          HTTP/1.1 200 OK
   831          Content-Type: application/x-tar
   832  
   833          {{ TAR STREAM }}
   834  
   835  Status Codes:
   836  
   837  -   **200** – no error
   838  -   **404** – no such container
   839  -   **500** – server error
   840  
   841  ## 2.2 Images
   842  
   843  ### List Images
   844  
   845  `GET /images/json`
   846  
   847  **Example request**:
   848  
   849          GET /images/json?all=0 HTTP/1.1
   850  
   851  **Example response**:
   852  
   853          HTTP/1.1 200 OK
   854          Content-Type: application/json
   855  
   856          [
   857            {
   858               "RepoTags": [
   859                 "ubuntu:12.04",
   860                 "ubuntu:precise",
   861                 "ubuntu:latest"
   862               ],
   863               "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   864               "Created": 1365714795,
   865               "Size": 131506275,
   866               "VirtualSize": 131506275
   867            },
   868            {
   869               "RepoTags": [
   870                 "ubuntu:12.10",
   871                 "ubuntu:quantal"
   872               ],
   873               "ParentId": "27cf784147099545",
   874               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   875               "Created": 1364102658,
   876               "Size": 24653,
   877               "VirtualSize": 180116135
   878            }
   879          ]
   880  
   881  
   882  Query Parameters:
   883  
   884  -   **all** – 1/True/true or 0/False/false, default false
   885  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
   886    -   dangling=true
   887  
   888  ### Create an image
   889  
   890  `POST /images/create`
   891  
   892  Create an image, either by pulling it from the registry or by importing it
   893  
   894  **Example request**:
   895  
   896          POST /images/create?fromImage=ubuntu HTTP/1.1
   897  
   898  **Example response**:
   899  
   900          HTTP/1.1 200 OK
   901          Content-Type: application/json
   902  
   903          {"status": "Pulling..."}
   904          {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
   905          {"error": "Invalid..."}
   906          ...
   907  
   908      When using this endpoint to pull an image from the registry, the
   909      `X-Registry-Auth` header can be used to include
   910      a base64-encoded AuthConfig object.
   911  
   912  Query Parameters:
   913  
   914  -   **fromImage** – name of the image to pull
   915  -   **fromSrc** – source to import.  The value may be a URL from which the image
   916          can be retrieved or `-` to read the image from the request body.
   917  -   **repo** – repository
   918  -   **tag** – tag
   919  -   **registry** – the registry to pull from
   920  
   921      Request Headers:
   922  
   923  -   **X-Registry-Auth** – base64-encoded AuthConfig object
   924  
   925  Status Codes:
   926  
   927  -   **200** – no error
   928  -   **500** – server error
   929  
   930  
   931  
   932  ### Inspect an image
   933  
   934  `GET /images/(name)/json`
   935  
   936  Return low-level information on the image `name`
   937  
   938  **Example request**:
   939  
   940          GET /images/ubuntu/json HTTP/1.1
   941  
   942  **Example response**:
   943  
   944          HTTP/1.1 200 OK
   945          Content-Type: application/json
   946  
   947          {
   948               "Created": "2013-03-23T22:24:18.818426-07:00",
   949               "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
   950               "ContainerConfig":
   951                       {
   952                               "Hostname": "",
   953                               "User": "",
   954                               "Memory": 0,
   955                               "MemorySwap": 0,
   956                               "AttachStdin": false,
   957                               "AttachStdout": false,
   958                               "AttachStderr": false,
   959                               "PortSpecs": null,
   960                               "Tty": true,
   961                               "OpenStdin": true,
   962                               "StdinOnce": false,
   963                               "Env": null,
   964                               "Cmd": ["/bin/bash"],
   965                               "Dns": null,
   966                               "Image": "ubuntu",
   967                               "Volumes": null,
   968                               "VolumesFrom": "",
   969                               "WorkingDir": ""
   970                       },
   971               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   972               "Parent": "27cf784147099545",
   973               "Size": 6824592
   974          }
   975  
   976  Status Codes:
   977  
   978  -   **200** – no error
   979  -   **404** – no such image
   980  -   **500** – server error
   981  
   982  ### Get the history of an image
   983  
   984  `GET /images/(name)/history`
   985  
   986  Return the history of the image `name`
   987  
   988  **Example request**:
   989  
   990          GET /images/ubuntu/history HTTP/1.1
   991  
   992  **Example response**:
   993  
   994          HTTP/1.1 200 OK
   995          Content-Type: application/json
   996  
   997          [
   998               {
   999                       "Id": "b750fe79269d",
  1000                       "Created": 1364102658,
  1001                       "CreatedBy": "/bin/bash"
  1002               },
  1003               {
  1004                       "Id": "27cf78414709",
  1005                       "Created": 1364068391,
  1006                       "CreatedBy": ""
  1007               }
  1008          ]
  1009  
  1010  Status Codes:
  1011  
  1012  -   **200** – no error
  1013  -   **404** – no such image
  1014  -   **500** – server error
  1015  
  1016  ### Push an image on the registry
  1017  
  1018  `POST /images/(name)/push`
  1019  
  1020  Push the image `name` on the registry
  1021  
  1022  **Example request**:
  1023  
  1024          POST /images/test/push HTTP/1.1
  1025  
  1026  **Example response**:
  1027  
  1028          HTTP/1.1 200 OK
  1029          Content-Type: application/json
  1030  
  1031          {"status": "Pushing..."}
  1032          {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1033          {"error": "Invalid..."}
  1034          ...
  1035  
  1036      If you wish to push an image on to a private registry, that image must already have been tagged
  1037      into a repository which references that registry host name and port.  This repository name should
  1038      then be used in the URL. This mirrors the flow of the CLI.
  1039  
  1040  **Example request**:
  1041  
  1042          POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1043  
  1044  
  1045  Query Parameters:
  1046  
  1047  -   **tag** – the tag to associate with the image on the registry, optional
  1048  
  1049  Request Headers:
  1050  
  1051  -   **X-Registry-Auth** – include a base64-encoded AuthConfig
  1052          object.
  1053  
  1054  Status Codes:
  1055  
  1056  -   **200** – no error
  1057  -   **404** – no such image
  1058  -   **500** – server error
  1059  
  1060  ### Tag an image into a repository
  1061  
  1062  `POST /images/(name)/tag`
  1063  
  1064  Tag the image `name` into a repository
  1065  
  1066  **Example request**:
  1067  
  1068          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1069  
  1070  **Example response**:
  1071  
  1072          HTTP/1.1 201 OK
  1073  
  1074  Query Parameters:
  1075  
  1076  -   **repo** – The repository to tag in
  1077  -   **force** – 1/True/true or 0/False/false, default false
  1078  -   **tag** - The new tag name
  1079  
  1080  Status Codes:
  1081  
  1082  -   **201** – no error
  1083  -   **400** – bad parameter
  1084  -   **404** – no such image
  1085  -   **409** – conflict
  1086  -   **500** – server error
  1087  
  1088  ### Remove an image
  1089  
  1090  `DELETE /images/(name)`
  1091  
  1092  Remove the image `name` from the filesystem
  1093  
  1094  **Example request**:
  1095  
  1096          DELETE /images/test HTTP/1.1
  1097  
  1098  **Example response**:
  1099  
  1100          HTTP/1.1 200 OK
  1101          Content-type: application/json
  1102  
  1103          [
  1104           {"Untagged": "3e2f21a89f"},
  1105           {"Deleted": "3e2f21a89f"},
  1106           {"Deleted": "53b4f83ac9"}
  1107          ]
  1108  
  1109  Query Parameters:
  1110  
  1111  -   **force** – 1/True/true or 0/False/false, default false
  1112  -   **noprune** – 1/True/true or 0/False/false, default false
  1113  
  1114  Status Codes:
  1115  
  1116  -   **200** – no error
  1117  -   **404** – no such image
  1118  -   **409** – conflict
  1119  -   **500** – server error
  1120  
  1121  ### Search images
  1122  
  1123  `GET /images/search`
  1124  
  1125  Search for an image on [Docker Hub](https://hub.docker.com).
  1126  
  1127  > **Note**:
  1128  > The response keys have changed from API v1.6 to reflect the JSON
  1129  > sent by the registry server to the docker daemon's request.
  1130  
  1131  **Example request**:
  1132  
  1133          GET /images/search?term=sshd HTTP/1.1
  1134  
  1135  **Example response**:
  1136  
  1137          HTTP/1.1 200 OK
  1138          Content-Type: application/json
  1139  
  1140          [
  1141                  {
  1142                      "description": "",
  1143                      "is_official": false,
  1144                      "is_automated": false,
  1145                      "name": "wma55/u1210sshd",
  1146                      "star_count": 0
  1147                  },
  1148                  {
  1149                      "description": "",
  1150                      "is_official": false,
  1151                      "is_automated": false,
  1152                      "name": "jdswinbank/sshd",
  1153                      "star_count": 0
  1154                  },
  1155                  {
  1156                      "description": "",
  1157                      "is_official": false,
  1158                      "is_automated": false,
  1159                      "name": "vgauthier/sshd",
  1160                      "star_count": 0
  1161                  }
  1162          ...
  1163          ]
  1164  
  1165  Query Parameters:
  1166  
  1167  -   **term** – term to search
  1168  
  1169  Status Codes:
  1170  
  1171  -   **200** – no error
  1172  -   **500** – server error
  1173  
  1174  ## 2.3 Misc
  1175  
  1176  ### Build an image from Dockerfile via stdin
  1177  
  1178  `POST /build`
  1179  
  1180  Build an image from Dockerfile via stdin
  1181  
  1182  **Example request**:
  1183  
  1184          POST /build HTTP/1.1
  1185  
  1186          {{ TAR STREAM }}
  1187  
  1188  **Example response**:
  1189  
  1190          HTTP/1.1 200 OK
  1191          Content-Type: application/json
  1192  
  1193          {"stream": "Step 1..."}
  1194          {"stream": "..."}
  1195          {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1196  
  1197      The stream must be a tar archive compressed with one of the
  1198      following algorithms: identity (no compression), gzip, bzip2, xz.
  1199  
  1200      The archive must include a file called `Dockerfile`
  1201      at its root. It may include any number of other files,
  1202      which will be accessible in the build context (See the [*ADD build
  1203      command*](/reference/builder/#dockerbuilder)).
  1204  
  1205  Query Parameters:
  1206  
  1207  -   **t** – repository name (and optionally a tag) to be applied to
  1208          the resulting image in case of success
  1209  -   **remote** – git or HTTP/HTTPS URI build source
  1210  -   **q** – suppress verbose build output
  1211  -   **nocache** – do not use the cache when building the image
  1212  -   **pull** - attempt to pull the image even if an older image exists locally
  1213  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1214  -   **forcerm** - always remove intermediate containers (includes rm)
  1215  
  1216      Request Headers:
  1217  
  1218  -   **Content-type** – should be set to `"application/tar"`.
  1219  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1220  
  1221  Status Codes:
  1222  
  1223  -   **200** – no error
  1224  -   **500** – server error
  1225  
  1226  ### Check auth configuration
  1227  
  1228  `POST /auth`
  1229  
  1230  Get the default username and email
  1231  
  1232  **Example request**:
  1233  
  1234          POST /auth HTTP/1.1
  1235          Content-Type: application/json
  1236  
  1237          {
  1238               "username":" hannibal",
  1239               "password: "xxxx",
  1240               "email": "hannibal@a-team.com",
  1241               "serveraddress": "https://index.docker.io/v1/"
  1242          }
  1243  
  1244  **Example response**:
  1245  
  1246          HTTP/1.1 200 OK
  1247  
  1248  Status Codes:
  1249  
  1250  -   **200** – no error
  1251  -   **204** – no error
  1252  -   **500** – server error
  1253  
  1254  ### Display system-wide information
  1255  
  1256  `GET /info`
  1257  
  1258  Display system-wide information
  1259  
  1260  **Example request**:
  1261  
  1262          GET /info HTTP/1.1
  1263  
  1264  **Example response**:
  1265  
  1266          HTTP/1.1 200 OK
  1267          Content-Type: application/json
  1268  
  1269          {
  1270               "Containers":11,
  1271               "Images":16,
  1272               "Driver":"btrfs",
  1273               "DriverStatus": [[""]],
  1274               "ExecutionDriver":"native-0.1",
  1275               "KernelVersion":"3.12.0-1-amd64"
  1276               "NCPU":1,
  1277               "MemTotal":2099236864,
  1278               "Name":"prod-server-42",
  1279               "ID":"7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1280               "Debug":false,
  1281               "NFd": 11,
  1282               "NGoroutines":21,
  1283               "NEventsListener":0,
  1284               "InitPath":"/usr/bin/docker",
  1285               "InitSha1":"",
  1286               "IndexServerAddress":["https://index.docker.io/v1/"],
  1287               "MemoryLimit":true,
  1288               "SwapLimit":false,
  1289               "IPv4Forwarding":true,
  1290               "Labels":["storage=ssd"],
  1291               "DockerRootDir": "/var/lib/docker",
  1292               "OperatingSystem": "Boot2Docker",
  1293          }
  1294  
  1295  Status Codes:
  1296  
  1297  -   **200** – no error
  1298  -   **500** – server error
  1299  
  1300  ### Show the docker version information
  1301  
  1302  `GET /version`
  1303  
  1304  Show the docker version information
  1305  
  1306  **Example request**:
  1307  
  1308          GET /version HTTP/1.1
  1309  
  1310  **Example response**:
  1311  
  1312          HTTP/1.1 200 OK
  1313          Content-Type: application/json
  1314  
  1315          {
  1316               "ApiVersion": "1.12",
  1317               "Version": "0.2.2",
  1318               "GitCommit": "5a2a5cc+CHANGES",
  1319               "GoVersion": "go1.0.3"
  1320          }
  1321  
  1322  Status Codes:
  1323  
  1324  -   **200** – no error
  1325  -   **500** – server error
  1326  
  1327  ### Ping the docker server
  1328  
  1329  `GET /_ping`
  1330  
  1331  Ping the docker server
  1332  
  1333  **Example request**:
  1334  
  1335          GET /_ping HTTP/1.1
  1336  
  1337  **Example response**:
  1338  
  1339          HTTP/1.1 200 OK
  1340          Content-Type: text/plain
  1341  
  1342          OK
  1343  
  1344  Status Codes:
  1345  
  1346  -   **200** - no error
  1347  -   **500** - server error
  1348  
  1349  ### Create a new image from a container's changes
  1350  
  1351  `POST /commit`
  1352  
  1353  Create a new image from a container's changes
  1354  
  1355  **Example request**:
  1356  
  1357          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1358          Content-Type: application/json
  1359  
  1360          {
  1361               "Hostname": "",
  1362               "Domainname": "",
  1363               "User": "",
  1364               "Memory": 0,
  1365               "MemorySwap": 0,
  1366               "CpuShares": 512,
  1367               "Cpuset": "0,1",
  1368               "AttachStdin": false,
  1369               "AttachStdout": true,
  1370               "AttachStderr": true,
  1371               "PortSpecs": null,
  1372               "Tty": false,
  1373               "OpenStdin": false,
  1374               "StdinOnce": false,
  1375               "Env": null,
  1376               "Cmd": [
  1377                       "date"
  1378               ],
  1379               "Volumes": {
  1380                       "/tmp": {}
  1381               },
  1382               "WorkingDir": "",
  1383               "NetworkDisabled": false,
  1384               "ExposedPorts": {
  1385                       "22/tcp": {}
  1386               }
  1387          }
  1388  
  1389  **Example response**:
  1390  
  1391          HTTP/1.1 201 Created
  1392          Content-Type: application/vnd.docker.raw-stream
  1393  
  1394          {"Id": "596069db4bf5"}
  1395  
  1396  Json Parameters:
  1397  
  1398  -  **config** - the container's configuration
  1399  
  1400  Query Parameters:
  1401  
  1402  -   **container** – source container
  1403  -   **repo** – repository
  1404  -   **tag** – tag
  1405  -   **comment** – commit message
  1406  -   **author** – author (e.g., "John Hannibal Smith
  1407      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1408  
  1409  Status Codes:
  1410  
  1411  -   **201** – no error
  1412  -   **404** – no such container
  1413  -   **500** – server error
  1414  
  1415  ### Monitor Docker's events
  1416  
  1417  `GET /events`
  1418  
  1419  Get container events from docker, either in real time via streaming, or via
  1420  polling (using since).
  1421  
  1422  Docker containers will report the following events:
  1423  
  1424      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1425  
  1426  and Docker images will report:
  1427  
  1428      untag, delete
  1429  
  1430  **Example request**:
  1431  
  1432          GET /events?since=1374067924
  1433  
  1434  **Example response**:
  1435  
  1436          HTTP/1.1 200 OK
  1437          Content-Type: application/json
  1438  
  1439          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1440          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1441          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1442          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1443  
  1444  Query Parameters:
  1445  
  1446  -   **since** – timestamp used for polling
  1447  -   **until** – timestamp used for polling
  1448  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1449    -   event=&lt;string&gt; -- event to filter
  1450    -   image=&lt;string&gt; -- image to filter
  1451    -   container=&lt;string&gt; -- container to filter
  1452  
  1453  Status Codes:
  1454  
  1455  -   **200** – no error
  1456  -   **500** – server error
  1457  
  1458  ### Get a tarball containing all images in a repository
  1459  
  1460  `GET /images/(name)/get`
  1461  
  1462  Get a tarball containing all images and metadata for the repository specified
  1463  by `name`.
  1464  
  1465  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1466  (and its parents) are returned. If `name` is an image ID, similarly only that
  1467  image (and its parents) are returned, but with the exclusion of the
  1468  'repositories' file in the tarball, as there were no image names referenced.
  1469  
  1470  See the [image tarball format](#image-tarball-format) for more details.
  1471  
  1472  **Example request**
  1473  
  1474          GET /images/ubuntu/get
  1475  
  1476  **Example response**:
  1477  
  1478          HTTP/1.1 200 OK
  1479          Content-Type: application/x-tar
  1480  
  1481          Binary data stream
  1482  
  1483  Status Codes:
  1484  
  1485  -   **200** – no error
  1486  -   **500** – server error
  1487  
  1488  ### Get a tarball containing all images.
  1489  
  1490  `GET /images/get`
  1491  
  1492  Get a tarball containing all images and metadata for one or more repositories.
  1493  
  1494  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1495  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1496  an image ID, similarly only that image (and its parents) are returned and there
  1497  would be no names referenced in the 'repositories' file for this image ID.
  1498  
  1499  See the [image tarball format](#image-tarball-format) for more details.
  1500  
  1501  **Example request**
  1502  
  1503          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1504  
  1505  **Example response**:
  1506  
  1507          HTTP/1.1 200 OK
  1508          Content-Type: application/x-tar
  1509  
  1510          Binary data stream
  1511  
  1512  Status Codes:
  1513  
  1514  -   **200** – no error
  1515  -   **500** – server error
  1516  
  1517  ### Load a tarball with a set of images and tags into docker
  1518  
  1519  `POST /images/load`
  1520  
  1521  Load a set of images and tags into the docker repository.
  1522  See the [image tarball format](#image-tarball-format) for more details.
  1523  
  1524  **Example request**
  1525  
  1526          POST /images/load
  1527  
  1528          Tarball in body
  1529  
  1530  **Example response**:
  1531  
  1532          HTTP/1.1 200 OK
  1533  
  1534  Status Codes:
  1535  
  1536  -   **200** – no error
  1537  -   **500** – server error
  1538  
  1539  ### Image tarball format
  1540  
  1541  An image tarball contains one directory per image layer (named using its long ID),
  1542  each containing three files:
  1543  
  1544  1. `VERSION`: currently `1.0` - the file format version
  1545  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1546  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1547  
  1548  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1549  for storing attribute changes and deletions.
  1550  
  1551  If the tarball defines a repository, there will also be a `repositories` file at
  1552  the root that contains a list of repository and tag names mapped to layer IDs.
  1553  
  1554  ```
  1555  {"hello-world":
  1556      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1557  }
  1558  ```
  1559  
  1560  ### Exec Create
  1561  
  1562  `POST /containers/(id)/exec`
  1563  
  1564  Sets up an exec instance in a running container `id`
  1565  
  1566  **Example request**:
  1567  
  1568          POST /containers/e90e34656806/exec HTTP/1.1
  1569          Content-Type: application/json
  1570  
  1571          {
  1572  	     "AttachStdin": false,
  1573  	     "AttachStdout": true,
  1574  	     "AttachStderr": true,
  1575  	     "Tty": false,
  1576  	     "Cmd": [
  1577                       "date"
  1578               ],
  1579          }
  1580  
  1581  **Example response**:
  1582  
  1583          HTTP/1.1 201 OK
  1584          Content-Type: application/json
  1585  
  1586          {
  1587               "Id": "f90e34656806"
  1588          }
  1589  
  1590  Json Parameters:
  1591  
  1592  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1593  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1594  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1595  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1596  -   **Cmd** - Command to run specified as a string or an array of strings.
  1597  
  1598  
  1599  Status Codes:
  1600  
  1601  -   **201** – no error
  1602  -   **404** – no such container
  1603  
  1604  ### Exec Start
  1605  
  1606  `POST /exec/(id)/start`
  1607  
  1608  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1609  returns after starting the `exec` command. Otherwise, this API sets up an
  1610  interactive session with the `exec` command.
  1611  
  1612  **Example request**:
  1613  
  1614          POST /exec/e90e34656806/start HTTP/1.1
  1615          Content-Type: application/json
  1616  
  1617          {
  1618  	     "Detach": false,
  1619  	     "Tty": false,
  1620          }
  1621  
  1622  **Example response**:
  1623  
  1624          HTTP/1.1 201 OK
  1625          Content-Type: application/json
  1626  
  1627          {{ STREAM }}
  1628  
  1629  Json Parameters:
  1630  
  1631  -   **Detach** - Detach from the exec command
  1632  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1633  
  1634  Status Codes:
  1635  
  1636  -   **201** – no error
  1637  -   **404** – no such exec instance
  1638  
  1639      **Stream details**:
  1640      Similar to the stream behavior of `POST /container/(id)/attach` API
  1641  
  1642  ### Exec Resize
  1643  
  1644  `POST /exec/(id)/resize`
  1645  
  1646  Resizes the tty session used by the exec command `id`.
  1647  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1648  
  1649  **Example request**:
  1650  
  1651          POST /exec/e90e34656806/resize HTTP/1.1
  1652          Content-Type: plain/text
  1653  
  1654  **Example response**:
  1655  
  1656          HTTP/1.1 201 OK
  1657          Content-Type: plain/text
  1658  
  1659  Query Parameters:
  1660  
  1661  -   **h** – height of tty session
  1662  -   **w** – width
  1663  
  1664  Status Codes:
  1665  
  1666  -   **201** – no error
  1667  -   **404** – no such exec instance
  1668  
  1669  ### Exec Inspect
  1670  
  1671  `GET /exec/(id)/json`
  1672  
  1673  Return low-level information about the exec command `id`.
  1674  
  1675  **Example request**:
  1676  
  1677          GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  1678  
  1679  **Example response**:
  1680  
  1681          HTTP/1.1 200 OK
  1682          Content-Type: plain/text
  1683  
  1684          {
  1685            "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  1686            "Running" : false,
  1687            "ExitCode" : 2,
  1688            "ProcessConfig" : {
  1689              "privileged" : false,
  1690              "user" : "",
  1691              "tty" : false,
  1692              "entrypoint" : "sh",
  1693              "arguments" : [
  1694                "-c",
  1695                "exit 2"
  1696              ]
  1697            },
  1698            "OpenStdin" : false,
  1699            "OpenStderr" : false,
  1700            "OpenStdout" : false,
  1701            "Container" : {
  1702              "State" : {
  1703                "Running" : true,
  1704                "Paused" : false,
  1705                "Restarting" : false,
  1706                "OOMKilled" : false,
  1707                "Pid" : 3650,
  1708                "ExitCode" : 0,
  1709                "Error" : "",
  1710                "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  1711                "FinishedAt" : "0001-01-01T00:00:00Z"
  1712              },
  1713              "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  1714              "Created" : "2014-11-17T22:26:03.626304998Z",
  1715              "Path" : "date",
  1716              "Args" : [],
  1717              "Config" : {
  1718                "Hostname" : "8f177a186b97",
  1719                "Domainname" : "",
  1720                "User" : "",
  1721                "Memory" : 0,
  1722                "MemorySwap" : 0,
  1723                "CpuShares" : 0,
  1724                "Cpuset" : "",
  1725                "AttachStdin" : false,
  1726                "AttachStdout" : false,
  1727                "AttachStderr" : false,
  1728                "PortSpecs" : null,
  1729                "ExposedPorts" : null,
  1730                "Tty" : false,
  1731                "OpenStdin" : false,
  1732                "StdinOnce" : false,
  1733                "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  1734                "Cmd" : [
  1735                  "date"
  1736                ],
  1737                "Image" : "ubuntu",
  1738                "Volumes" : null,
  1739                "WorkingDir" : "",
  1740                "Entrypoint" : null,
  1741                "NetworkDisabled" : false,
  1742                "MacAddress" : "",
  1743                "OnBuild" : null,
  1744                "SecurityOpt" : null
  1745              },
  1746              "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  1747              "NetworkSettings" : {
  1748                "IPAddress" : "172.17.0.2",
  1749                "IPPrefixLen" : 16,
  1750                "MacAddress" : "02:42:ac:11:00:02",
  1751                "Gateway" : "172.17.42.1",
  1752                "Bridge" : "docker0",
  1753                "PortMapping" : null,
  1754                "Ports" : {}
  1755              },
  1756              "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  1757              "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  1758              "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  1759              "Name" : "/test",
  1760              "Driver" : "aufs",
  1761              "ExecDriver" : "native-0.2",
  1762              "MountLabel" : "",
  1763              "ProcessLabel" : "",
  1764              "AppArmorProfile" : "",
  1765              "RestartCount" : 0,
  1766              "Volumes" : {},
  1767              "VolumesRW" : {}
  1768            }
  1769          }
  1770  
  1771  Status Codes:
  1772  
  1773  -   **200** – no error
  1774  -   **404** – no such exec instance
  1775  -   **500** - server error
  1776  
  1777  # 3. Going further
  1778  
  1779  ## 3.1 Inside `docker run`
  1780  
  1781  As an example, the `docker run` command line makes the following API calls:
  1782  
  1783  - Create the container
  1784  
  1785  - If the status code is 404, it means the image doesn't exist:
  1786      - Try to pull it
  1787      - Then retry to create the container
  1788  
  1789  - Start the container
  1790  
  1791  - If you are not in detached mode:
  1792  - Attach to the container, using logs=1 (to have stdout and
  1793        stderr from the container's start) and stream=1
  1794  
  1795  - If in detached mode or only stdin is attached:
  1796  - Display the container's id
  1797  
  1798  ## 3.2 Hijacking
  1799  
  1800  In this version of the API, /attach, uses hijacking to transport stdin,
  1801  stdout and stderr on the same socket. This might change in the future.
  1802  
  1803  ## 3.3 CORS Requests
  1804  
  1805  To enable cross origin requests to the remote api add the flag
  1806  "--api-enable-cors" when running docker in daemon mode.
  1807  
  1808      $ docker -d -H="192.168.1.9:2375" --api-enable-cors