github.com/stchris/docker@v1.4.2-0.20150106053530-1510a324dbd5/docs/sources/reference/api/docker_remote_api_v1.17.md (about)

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