github.com/nf/docker@v1.8.1/docs/reference/api/docker_remote_api_v1.16.md (about)

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