github.com/daaku/docker@v1.5.0/docs/sources/reference/api/docker_remote_api_v1.16.md (about)

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