github.com/eikeon/docker@v1.5.0-rc4/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  -   **q** – suppress verbose build output
  1202  -   **nocache** – do not use the cache when building the image
  1203  -   **pull** - attempt to pull the image even if an older image exists locally
  1204  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1205  -   **forcerm** - always remove intermediate containers (includes rm)
  1206  
  1207      Request Headers:
  1208  
  1209  -   **Content-type** – should be set to `"application/tar"`.
  1210  -   **X-Registry-Config** – base64-encoded ConfigFile objec
  1211  
  1212  Status Codes:
  1213  
  1214  -   **200** – no error
  1215  -   **500** – server error
  1216  
  1217  ### Check auth configuration
  1218  
  1219  `POST /auth`
  1220  
  1221  Get the default username and email
  1222  
  1223  **Example request**:
  1224  
  1225          POST /auth HTTP/1.1
  1226          Content-Type: application/json
  1227  
  1228          {
  1229               "username":" hannibal",
  1230               "password: "xxxx",
  1231               "email": "hannibal@a-team.com",
  1232               "serveraddress": "https://index.docker.io/v1/"
  1233          }
  1234  
  1235  **Example response**:
  1236  
  1237          HTTP/1.1 200 OK
  1238  
  1239  Status Codes:
  1240  
  1241  -   **200** – no error
  1242  -   **204** – no error
  1243  -   **500** – server error
  1244  
  1245  ### Display system-wide information
  1246  
  1247  `GET /info`
  1248  
  1249  Display system-wide information
  1250  
  1251  **Example request**:
  1252  
  1253          GET /info HTTP/1.1
  1254  
  1255  **Example response**:
  1256  
  1257          HTTP/1.1 200 OK
  1258          Content-Type: application/json
  1259  
  1260          {
  1261               "Containers":11,
  1262               "Images":16,
  1263               "Driver":"btrfs",
  1264               "DriverStatus": [[""]],
  1265               "ExecutionDriver":"native-0.1",
  1266               "KernelVersion":"3.12.0-1-amd64"
  1267               "NCPU":1,
  1268               "MemTotal":2099236864,
  1269               "Name":"prod-server-42",
  1270               "ID":"7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1271               "Debug":false,
  1272               "NFd": 11,
  1273               "NGoroutines":21,
  1274               "NEventsListener":0,
  1275               "InitPath":"/usr/bin/docker",
  1276               "InitSha1":"",
  1277               "IndexServerAddress":["https://index.docker.io/v1/"],
  1278               "MemoryLimit":true,
  1279               "SwapLimit":false,
  1280               "IPv4Forwarding":true,
  1281               "Labels":["storage=ssd"],
  1282               "DockerRootDir": "/var/lib/docker",
  1283               "OperatingSystem": "Boot2Docker",
  1284          }
  1285  
  1286  Status Codes:
  1287  
  1288  -   **200** – no error
  1289  -   **500** – server error
  1290  
  1291  ### Show the docker version information
  1292  
  1293  `GET /version`
  1294  
  1295  Show the docker version information
  1296  
  1297  **Example request**:
  1298  
  1299          GET /version HTTP/1.1
  1300  
  1301  **Example response**:
  1302  
  1303          HTTP/1.1 200 OK
  1304          Content-Type: application/json
  1305  
  1306          {
  1307               "ApiVersion": "1.12",
  1308               "Version": "0.2.2",
  1309               "GitCommit": "5a2a5cc+CHANGES",
  1310               "GoVersion": "go1.0.3"
  1311          }
  1312  
  1313  Status Codes:
  1314  
  1315  -   **200** – no error
  1316  -   **500** – server error
  1317  
  1318  ### Ping the docker server
  1319  
  1320  `GET /_ping`
  1321  
  1322  Ping the docker server
  1323  
  1324  **Example request**:
  1325  
  1326          GET /_ping HTTP/1.1
  1327  
  1328  **Example response**:
  1329  
  1330          HTTP/1.1 200 OK
  1331          Content-Type: text/plain
  1332  
  1333          OK
  1334  
  1335  Status Codes:
  1336  
  1337  -   **200** - no error
  1338  -   **500** - server error
  1339  
  1340  ### Create a new image from a container's changes
  1341  
  1342  `POST /commit`
  1343  
  1344  Create a new image from a container's changes
  1345  
  1346  **Example request**:
  1347  
  1348          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1349          Content-Type: application/json
  1350  
  1351          {
  1352               "Hostname": "",
  1353               "Domainname": "",
  1354               "User": "",
  1355               "Memory": 0,
  1356               "MemorySwap": 0,
  1357               "CpuShares": 512,
  1358               "Cpuset": "0,1",
  1359               "AttachStdin": false,
  1360               "AttachStdout": true,
  1361               "AttachStderr": true,
  1362               "PortSpecs": null,
  1363               "Tty": false,
  1364               "OpenStdin": false,
  1365               "StdinOnce": false,
  1366               "Env": null,
  1367               "Cmd": [
  1368                       "date"
  1369               ],
  1370               "Volumes": {
  1371                       "/tmp": {}
  1372               },
  1373               "WorkingDir": "",
  1374               "NetworkDisabled": false,
  1375               "ExposedPorts": {
  1376                       "22/tcp": {}
  1377               }
  1378          }
  1379  
  1380  **Example response**:
  1381  
  1382          HTTP/1.1 201 Created
  1383          Content-Type: application/vnd.docker.raw-stream
  1384  
  1385          {"Id": "596069db4bf5"}
  1386  
  1387  Json Parameters:
  1388  
  1389  -  **config** - the container's configuration
  1390  
  1391  Query Parameters:
  1392  
  1393  -   **container** – source container
  1394  -   **repo** – repository
  1395  -   **tag** – tag
  1396  -   **comment** – commit message
  1397  -   **author** – author (e.g., "John Hannibal Smith
  1398      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1399  
  1400  Status Codes:
  1401  
  1402  -   **201** – no error
  1403  -   **404** – no such container
  1404  -   **500** – server error
  1405  
  1406  ### Monitor Docker's events
  1407  
  1408  `GET /events`
  1409  
  1410  Get container events from docker, either in real time via streaming, or via
  1411  polling (using since).
  1412  
  1413  Docker containers will report the following events:
  1414  
  1415      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1416  
  1417  and Docker images will report:
  1418  
  1419      untag, delete
  1420  
  1421  **Example request**:
  1422  
  1423          GET /events?since=1374067924
  1424  
  1425  **Example response**:
  1426  
  1427          HTTP/1.1 200 OK
  1428          Content-Type: application/json
  1429  
  1430          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1431          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1432          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1433          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1434  
  1435  Query Parameters:
  1436  
  1437  -   **since** – timestamp used for polling
  1438  -   **until** – timestamp used for polling
  1439  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1440    -   event=&lt;string&gt; -- event to filter
  1441    -   image=&lt;string&gt; -- image to filter
  1442    -   container=&lt;string&gt; -- container to filter
  1443  
  1444  Status Codes:
  1445  
  1446  -   **200** – no error
  1447  -   **500** – server error
  1448  
  1449  ### Get a tarball containing all images in a repository
  1450  
  1451  `GET /images/(name)/get`
  1452  
  1453  Get a tarball containing all images and metadata for the repository specified
  1454  by `name`.
  1455  
  1456  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1457  (and its parents) are returned. If `name` is an image ID, similarly only tha
  1458  image (and its parents) are returned, but with the exclusion of the
  1459  'repositories' file in the tarball, as there were no image names referenced.
  1460  
  1461  See the [image tarball format](#image-tarball-format) for more details.
  1462  
  1463  **Example request**
  1464  
  1465          GET /images/ubuntu/get
  1466  
  1467  **Example response**:
  1468  
  1469          HTTP/1.1 200 OK
  1470          Content-Type: application/x-tar
  1471  
  1472          Binary data stream
  1473  
  1474  Status Codes:
  1475  
  1476  -   **200** – no error
  1477  -   **500** – server error
  1478  
  1479  ### Get a tarball containing all images.
  1480  
  1481  `GET /images/get`
  1482  
  1483  Get a tarball containing all images and metadata for one or more repositories.
  1484  
  1485  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1486  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1487  an image ID, similarly only that image (and its parents) are returned and there
  1488  would be no names referenced in the 'repositories' file for this image ID.
  1489  
  1490  See the [image tarball format](#image-tarball-format) for more details.
  1491  
  1492  **Example request**
  1493  
  1494          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1495  
  1496  **Example response**:
  1497  
  1498          HTTP/1.1 200 OK
  1499          Content-Type: application/x-tar
  1500  
  1501          Binary data stream
  1502  
  1503  Status Codes:
  1504  
  1505  -   **200** – no error
  1506  -   **500** – server error
  1507  
  1508  ### Load a tarball with a set of images and tags into docker
  1509  
  1510  `POST /images/load`
  1511  
  1512  Load a set of images and tags into the docker repository.
  1513  See the [image tarball format](#image-tarball-format) for more details.
  1514  
  1515  **Example request**
  1516  
  1517          POST /images/load
  1518  
  1519          Tarball in body
  1520  
  1521  **Example response**:
  1522  
  1523          HTTP/1.1 200 OK
  1524  
  1525  Status Codes:
  1526  
  1527  -   **200** – no error
  1528  -   **500** – server error
  1529  
  1530  ### Image tarball format
  1531  
  1532  An image tarball contains one directory per image layer (named using its long ID),
  1533  each containing three files:
  1534  
  1535  1. `VERSION`: currently `1.0` - the file format version
  1536  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1537  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1538  
  1539  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1540  for storing attribute changes and deletions.
  1541  
  1542  If the tarball defines a repository, there will also be a `repositories` file at
  1543  the root that contains a list of repository and tag names mapped to layer IDs.
  1544  
  1545  ```
  1546  {"hello-world":
  1547      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1548  }
  1549  ```
  1550  
  1551  ### Exec Create
  1552  
  1553  `POST /containers/(id)/exec`
  1554  
  1555  Sets up an exec instance in a running container `id`
  1556  
  1557  **Example request**:
  1558  
  1559          POST /containers/e90e34656806/exec HTTP/1.1
  1560          Content-Type: application/json
  1561  
  1562          {
  1563  	     "AttachStdin": false,
  1564  	     "AttachStdout": true,
  1565  	     "AttachStderr": true,
  1566  	     "Tty": false,
  1567  	     "Cmd": [
  1568                       "date"
  1569               ],
  1570          }
  1571  
  1572  **Example response**:
  1573  
  1574          HTTP/1.1 201 OK
  1575          Content-Type: application/json
  1576  
  1577          {
  1578               "Id": "f90e34656806"
  1579          }
  1580  
  1581  Json Parameters:
  1582  
  1583  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1584  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1585  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1586  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1587  -   **Cmd** - Command to run specified as a string or an array of strings.
  1588  
  1589  
  1590  Status Codes:
  1591  
  1592  -   **201** – no error
  1593  -   **404** – no such container
  1594  
  1595  ### Exec Start
  1596  
  1597  `POST /exec/(id)/start`
  1598  
  1599  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1600  returns after starting the `exec` command. Otherwise, this API sets up an
  1601  interactive session with the `exec` command.
  1602  
  1603  **Example request**:
  1604  
  1605          POST /exec/e90e34656806/start HTTP/1.1
  1606          Content-Type: application/json
  1607  
  1608          {
  1609  	     "Detach": false,
  1610  	     "Tty": false,
  1611          }
  1612  
  1613  **Example response**:
  1614  
  1615          HTTP/1.1 201 OK
  1616          Content-Type: application/json
  1617  
  1618          {{ STREAM }}
  1619  
  1620  Json Parameters:
  1621  
  1622  -   **Detach** - Detach from the exec command
  1623  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1624  
  1625  Status Codes:
  1626  
  1627  -   **201** – no error
  1628  -   **404** – no such exec instance
  1629  
  1630      **Stream details**:
  1631      Similar to the stream behavior of `POST /container/(id)/attach` API
  1632  
  1633  ### Exec Resize
  1634  
  1635  `POST /exec/(id)/resize`
  1636  
  1637  Resizes the tty session used by the exec command `id`.
  1638  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1639  
  1640  **Example request**:
  1641  
  1642          POST /exec/e90e34656806/resize HTTP/1.1
  1643          Content-Type: plain/text
  1644  
  1645  **Example response**:
  1646  
  1647          HTTP/1.1 201 OK
  1648          Content-Type: plain/text
  1649  
  1650  Query Parameters:
  1651  
  1652  -   **h** – height of tty session
  1653  -   **w** – width
  1654  
  1655  Status Codes:
  1656  
  1657  -   **201** – no error
  1658  -   **404** – no such exec instance
  1659  
  1660  ### Exec Inspect
  1661  
  1662  `GET /exec/(id)/json`
  1663  
  1664  Return low-level information about the exec command `id`.
  1665  
  1666  **Example request**:
  1667  
  1668          GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  1669  
  1670  **Example response**:
  1671  
  1672          HTTP/1.1 200 OK
  1673          Content-Type: plain/text
  1674  
  1675          {
  1676            "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  1677            "Running" : false,
  1678            "ExitCode" : 2,
  1679            "ProcessConfig" : {
  1680              "privileged" : false,
  1681              "user" : "",
  1682              "tty" : false,
  1683              "entrypoint" : "sh",
  1684              "arguments" : [
  1685                "-c",
  1686                "exit 2"
  1687              ]
  1688            },
  1689            "OpenStdin" : false,
  1690            "OpenStderr" : false,
  1691            "OpenStdout" : false,
  1692            "Container" : {
  1693              "State" : {
  1694                "Running" : true,
  1695                "Paused" : false,
  1696                "Restarting" : false,
  1697                "OOMKilled" : false,
  1698                "Pid" : 3650,
  1699                "ExitCode" : 0,
  1700                "Error" : "",
  1701                "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  1702                "FinishedAt" : "0001-01-01T00:00:00Z"
  1703              },
  1704              "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  1705              "Created" : "2014-11-17T22:26:03.626304998Z",
  1706              "Path" : "date",
  1707              "Args" : [],
  1708              "Config" : {
  1709                "Hostname" : "8f177a186b97",
  1710                "Domainname" : "",
  1711                "User" : "",
  1712                "Memory" : 0,
  1713                "MemorySwap" : 0,
  1714                "CpuShares" : 0,
  1715                "Cpuset" : "",
  1716                "AttachStdin" : false,
  1717                "AttachStdout" : false,
  1718                "AttachStderr" : false,
  1719                "PortSpecs" : null,
  1720                "ExposedPorts" : null,
  1721                "Tty" : false,
  1722                "OpenStdin" : false,
  1723                "StdinOnce" : false,
  1724                "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  1725                "Cmd" : [
  1726                  "date"
  1727                ],
  1728                "Image" : "ubuntu",
  1729                "Volumes" : null,
  1730                "WorkingDir" : "",
  1731                "Entrypoint" : null,
  1732                "NetworkDisabled" : false,
  1733                "MacAddress" : "",
  1734                "OnBuild" : null,
  1735                "SecurityOpt" : null
  1736              },
  1737              "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  1738              "NetworkSettings" : {
  1739                "IPAddress" : "172.17.0.2",
  1740                "IPPrefixLen" : 16,
  1741                "MacAddress" : "02:42:ac:11:00:02",
  1742                "Gateway" : "172.17.42.1",
  1743                "Bridge" : "docker0",
  1744                "PortMapping" : null,
  1745                "Ports" : {}
  1746              },
  1747              "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  1748              "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  1749              "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  1750              "Name" : "/test",
  1751              "Driver" : "aufs",
  1752              "ExecDriver" : "native-0.2",
  1753              "MountLabel" : "",
  1754              "ProcessLabel" : "",
  1755              "AppArmorProfile" : "",
  1756              "RestartCount" : 0,
  1757              "Volumes" : {},
  1758              "VolumesRW" : {}
  1759            }
  1760          }
  1761  
  1762  Status Codes:
  1763  
  1764  -   **200** – no error
  1765  -   **404** – no such exec instance
  1766  -   **500** - server error
  1767  
  1768  # 3. Going further
  1769  
  1770  ## 3.1 Inside `docker run`
  1771  
  1772  As an example, the `docker run` command line makes the following API calls:
  1773  
  1774  - Create the container
  1775  
  1776  - If the status code is 404, it means the image doesn't exist:
  1777      - Try to pull it
  1778      - Then retry to create the container
  1779  
  1780  - Start the container
  1781  
  1782  - If you are not in detached mode:
  1783  - Attach to the container, using logs=1 (to have stdout and
  1784        stderr from the container's start) and stream=1
  1785  
  1786  - If in detached mode or only stdin is attached:
  1787  - Display the container's id
  1788  
  1789  ## 3.2 Hijacking
  1790  
  1791  In this version of the API, /attach, uses hijacking to transport stdin,
  1792  stdout and stderr on the same socket. This might change in the future.
  1793  
  1794  ## 3.3 CORS Requests
  1795  
  1796  To enable cross origin requests to the remote api add the flag
  1797  "--api-enable-cors" when running docker in daemon mode.
  1798  
  1799      $ docker -d -H="192.168.1.9:2375" --api-enable-cors