github.com/endocode/docker@v1.4.2-0.20160113120958-46eb4700391e/docs/reference/api/docker_remote_api_v1.20.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.20"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent="smn_remoteapi"
     8  weight = 1
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.20
    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](../../userguide/basics.md#bind-docker-to-another-host-port-or-a-unix-socket).
    19   - The API tends to be REST. However, for some complex commands, like `attach`
    20     or `pull`, the HTTP connection is hijacked to transport `stdout`,
    21     `stdin` and `stderr`.
    22   - When the client API version is newer than the daemon's, these calls return an HTTP
    23     `400 Bad Request` error message.
    24  
    25  # 2. Endpoints
    26  
    27  ## 2.1 Containers
    28  
    29  ### List containers
    30  
    31  `GET /containers/json`
    32  
    33  List containers
    34  
    35  **Example request**:
    36  
    37      GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    38  
    39  **Example response**:
    40  
    41      HTTP/1.1 200 OK
    42      Content-Type: application/json
    43  
    44      [
    45           {
    46                   "Id": "8dfafdbc3a40",
    47                   "Names":["/boring_feynman"],
    48                   "Image": "ubuntu:latest",
    49                   "Command": "echo 1",
    50                   "Created": 1367854155,
    51                   "Status": "Exit 0",
    52                   "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    53                   "Labels": {
    54                           "com.example.vendor": "Acme",
    55                           "com.example.license": "GPL",
    56                           "com.example.version": "1.0"
    57                   },
    58                   "SizeRw": 12288,
    59                   "SizeRootFs": 0
    60           },
    61           {
    62                   "Id": "9cd87474be90",
    63                   "Names":["/coolName"],
    64                   "Image": "ubuntu:latest",
    65                   "Command": "echo 222222",
    66                   "Created": 1367854155,
    67                   "Status": "Exit 0",
    68                   "Ports": [],
    69                   "Labels": {},
    70                   "SizeRw": 12288,
    71                   "SizeRootFs": 0
    72           },
    73           {
    74                   "Id": "3176a2479c92",
    75                   "Names":["/sleepy_dog"],
    76                   "Image": "ubuntu:latest",
    77                   "Command": "echo 3333333333333333",
    78                   "Created": 1367854154,
    79                   "Status": "Exit 0",
    80                   "Ports":[],
    81                   "Labels": {},
    82                   "SizeRw":12288,
    83                   "SizeRootFs":0
    84           },
    85           {
    86                   "Id": "4cb07b47f9fb",
    87                   "Names":["/running_cat"],
    88                   "Image": "ubuntu:latest",
    89                   "Command": "echo 444444444444444444444444444444444",
    90                   "Created": 1367854152,
    91                   "Status": "Exit 0",
    92                   "Ports": [],
    93                   "Labels": {},
    94                   "SizeRw": 12288,
    95                   "SizeRootFs": 0
    96           }
    97      ]
    98  
    99  Query Parameters:
   100  
   101  -   **all** – 1/True/true or 0/False/false, Show all containers.
   102          Only running containers are shown by default (i.e., this defaults to false)
   103  -   **limit** – Show `limit` last created
   104          containers, include non-running ones.
   105  -   **since** – Show only containers created since Id, include
   106          non-running ones.
   107  -   **before** – Show only containers created before Id, include
   108          non-running ones.
   109  -   **size** – 1/True/true or 0/False/false, Show the containers
   110          sizes
   111  -   **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
   112    -   `exited=<int>`; -- containers with exit code of  `<int>` ;
   113    -   `status=`(`created`|`restarting`|`running`|`paused`|`exited`)
   114    -   `label=key` or `label="key=value"` of a container label
   115  
   116  Status Codes:
   117  
   118  -   **200** – no error
   119  -   **400** – bad parameter
   120  -   **500** – server error
   121  
   122  ### Create a container
   123  
   124  `POST /containers/create`
   125  
   126  Create a container
   127  
   128  **Example request**:
   129  
   130      POST /containers/create HTTP/1.1
   131      Content-Type: application/json
   132  
   133      {
   134             "Hostname": "",
   135             "Domainname": "",
   136             "User": "",
   137             "AttachStdin": false,
   138             "AttachStdout": true,
   139             "AttachStderr": true,
   140             "Tty": false,
   141             "OpenStdin": false,
   142             "StdinOnce": false,
   143             "Env": [
   144                     "FOO=bar",
   145                     "BAZ=quux"
   146             ],
   147             "Cmd": [
   148                     "date"
   149             ],
   150             "Entrypoint": "",
   151             "Image": "ubuntu",
   152             "Labels": {
   153                     "com.example.vendor": "Acme",
   154                     "com.example.license": "GPL",
   155                     "com.example.version": "1.0"
   156             },
   157             "Mounts": [
   158               {
   159                 "Source": "/data",
   160                 "Destination": "/data",
   161                 "Mode": "ro,Z",
   162                 "RW": false
   163               }
   164             ],
   165             "WorkingDir": "",
   166             "NetworkDisabled": false,
   167             "MacAddress": "12:34:56:78:9a:bc",
   168             "ExposedPorts": {
   169                     "22/tcp": {}
   170             },
   171             "HostConfig": {
   172               "Binds": ["/tmp:/tmp"],
   173               "Links": ["redis3:redis"],
   174               "LxcConf": {"lxc.utsname":"docker"},
   175               "Memory": 0,
   176               "MemorySwap": 0,
   177               "CpuShares": 512,
   178               "CpuPeriod": 100000,
   179               "CpuQuota": 50000,
   180               "CpusetCpus": "0,1",
   181               "CpusetMems": "0,1",
   182               "BlkioWeight": 300,
   183               "MemorySwappiness": 60,
   184               "OomKillDisable": false,
   185               "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   186               "PublishAllPorts": false,
   187               "Privileged": false,
   188               "ReadonlyRootfs": false,
   189               "Dns": ["8.8.8.8"],
   190               "DnsSearch": [""],
   191               "ExtraHosts": null,
   192               "VolumesFrom": ["parent", "other:ro"],
   193               "CapAdd": ["NET_ADMIN"],
   194               "CapDrop": ["MKNOD"],
   195               "GroupAdd": ["newgroup"],
   196               "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   197               "NetworkMode": "bridge",
   198               "Devices": [],
   199               "Ulimits": [{}],
   200               "LogConfig": { "Type": "json-file", "Config": {} },
   201               "SecurityOpt": [""],
   202               "CgroupParent": ""
   203            }
   204        }
   205  
   206  **Example response**:
   207  
   208        HTTP/1.1 201 Created
   209        Content-Type: application/json
   210  
   211        {
   212             "Id":"e90e34656806",
   213             "Warnings":[]
   214        }
   215  
   216  Json Parameters:
   217  
   218  -   **Hostname** - A string value containing the hostname to use for the
   219        container.
   220  -   **Domainname** - A string value containing the domain name to use
   221        for the container.
   222  -   **User** - A string value specifying the user inside the container.
   223  -   **Memory** - Memory limit in bytes.
   224  -   **MemorySwap** - Total memory limit (memory + swap); set `-1` to disable swap
   225        You must use this with `memory` and make the swap value larger than `memory`.
   226  -   **CpuShares** - An integer value containing the container's CPU Shares
   227        (ie. the relative weight vs other containers).
   228  -   **CpuPeriod** - The length of a CPU period in microseconds.
   229  -   **CpuQuota** - Microseconds of CPU time that the container can get in a CPU period.
   230  -   **Cpuset** - Deprecated please don't use. Use `CpusetCpus` instead. 
   231  -   **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use.
   232  -   **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
   233  -   **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
   234  -   **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
   235  -   **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
   236  -   **AttachStdin** - Boolean value, attaches to `stdin`.
   237  -   **AttachStdout** - Boolean value, attaches to `stdout`.
   238  -   **AttachStderr** - Boolean value, attaches to `stderr`.
   239  -   **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
   240  -   **OpenStdin** - Boolean value, opens stdin,
   241  -   **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects.
   242  -   **Env** - A list of environment variables in the form of `["VAR=value"[,"VAR2=value2"]]`
   243  -   **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
   244  -   **Cmd** - Command to run specified as a string or an array of strings.
   245  -   **Entrypoint** - Set the entry point for the container as a string or an array
   246        of strings.
   247  -   **Image** - A string specifying the image name to use for the container.
   248  -   **Mounts** - An array of mount points in the container.
   249  -   **WorkingDir** - A string specifying the working directory for commands to
   250        run in.
   251  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   252        container
   253  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   254        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   255  -   **HostConfig**
   256      -   **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
   257             + `container_path` to create a new volume for the container
   258             + `host_path:container_path` to bind-mount a host path into the container
   259             + `host_path:container_path:ro` to make the bind-mount read-only inside the container.
   260      -   **Links** - A list of links for the container. Each link entry should be
   261            in the form of `container_name:alias`.
   262      -   **LxcConf** - LXC specific configurations. These configurations only
   263            work when using the `lxc` execution driver.
   264      -   **PortBindings** - A map of exposed container ports and the host port they
   265            should map to. A JSON object in the form
   266            `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   267            Take note that `port` is specified as a string and not an integer value.
   268      -   **PublishAllPorts** - Allocates a random host port for all of a container's
   269            exposed ports. Specified as a boolean value.
   270      -   **Privileged** - Gives the container full access to the host. Specified as
   271            a boolean value.
   272      -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   273            Specified as a boolean value.
   274      -   **Dns** - A list of DNS servers for the container to use.
   275      -   **DnsSearch** - A list of DNS search domains
   276      -   **ExtraHosts** - A list of hostnames/IP mappings to add to the
   277          container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   278      -   **VolumesFrom** - A list of volumes to inherit from another container.
   279            Specified in the form `<container name>[:<ro|rw>]`
   280      -   **CapAdd** - A list of kernel capabilities to add to the container.
   281      -   **Capdrop** - A list of kernel capabilities to drop from the container.
   282      -   **GroupAdd** - A list of additional groups that the container process will run as
   283      -   **RestartPolicy** – The behavior to apply when the container exits.  The
   284              value is an object with a `Name` property of either `"always"` to
   285              always restart or `"on-failure"` to restart only when the container
   286              exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   287              controls the number of times to retry before giving up.
   288              The default is not to restart. (optional)
   289              An ever increasing delay (double the previous delay, starting at 100mS)
   290              is added before each restart to prevent flooding the server.
   291      -   **NetworkMode** - Sets the networking mode for the container. Supported
   292            values are: `bridge`, `host`, and `container:<name|id>`
   293      -   **Devices** - A list of devices to add to the container specified as a JSON object in the
   294        form
   295            `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   296      -   **Ulimits** - A list of ulimits to set in the container, specified as
   297            `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   298            `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }`
   299      -   **SecurityOpt**: A list of string values to customize labels for MLS
   300          systems, such as SELinux.
   301      -   **LogConfig** - Log configuration for the container, specified as a JSON object in the form
   302            `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   303            Available types: `json-file`, `syslog`, `journald`, `gelf`, `none`.
   304            `json-file` logging driver.
   305      -   **CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
   306  
   307  Query Parameters:
   308  
   309  -   **name** – Assign the specified name to the container. Must
   310      match `/?[a-zA-Z0-9_-]+`.
   311  
   312  Status Codes:
   313  
   314  -   **201** – no error
   315  -   **404** – no such container
   316  -   **406** – impossible to attach (container not running)
   317  -   **500** – server error
   318  
   319  ### Inspect a container
   320  
   321  `GET /containers/(id)/json`
   322  
   323  Return low-level information on the container `id`
   324  
   325  
   326  **Example request**:
   327  
   328        GET /containers/4fa6e0f0c678/json HTTP/1.1
   329  
   330  **Example response**:
   331  
   332      HTTP/1.1 200 OK
   333      Content-Type: application/json
   334  
   335      {
   336  		"AppArmorProfile": "",
   337  		"Args": [
   338  			"-c",
   339  			"exit 9"
   340  		],
   341  		"Config": {
   342  			"AttachStderr": true,
   343  			"AttachStdin": false,
   344  			"AttachStdout": true,
   345  			"Cmd": [
   346  				"/bin/sh",
   347  				"-c",
   348  				"exit 9"
   349  			],
   350  			"Domainname": "",
   351  			"Entrypoint": null,
   352  			"Env": [
   353  				"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   354  			],
   355  			"ExposedPorts": null,
   356  			"Hostname": "ba033ac44011",
   357  			"Image": "ubuntu",
   358  			"Labels": {
   359  				"com.example.vendor": "Acme",
   360  				"com.example.license": "GPL",
   361  				"com.example.version": "1.0"
   362  			},
   363  			"MacAddress": "",
   364  			"NetworkDisabled": false,
   365  			"OnBuild": null,
   366  			"OpenStdin": false,
   367  			"StdinOnce": false,
   368  			"Tty": false,
   369  			"User": "",
   370  			"Volumes": null,
   371  			"WorkingDir": ""
   372  		},
   373  		"Created": "2015-01-06T15:47:31.485331387Z",
   374  		"Driver": "devicemapper",
   375  		"ExecDriver": "native-0.2",
   376  		"ExecIDs": null,
   377  		"HostConfig": {
   378  			"Binds": null,
   379  			"BlkioWeight": 0,
   380  			"CapAdd": null,
   381  			"CapDrop": null,
   382  			"ContainerIDFile": "",
   383  			"CpusetCpus": "",
   384  			"CpusetMems": "",
   385  			"CpuShares": 0,
   386  			"CpuPeriod": 100000,
   387  			"Devices": [],
   388  			"Dns": null,
   389  			"DnsSearch": null,
   390  			"ExtraHosts": null,
   391  			"IpcMode": "",
   392  			"Links": null,
   393  			"LxcConf": [],
   394  			"Memory": 0,
   395  			"MemorySwap": 0,
   396  			"OomKillDisable": false,
   397  			"NetworkMode": "bridge",
   398  			"PortBindings": {},
   399  			"Privileged": false,
   400  			"ReadonlyRootfs": false,
   401  			"PublishAllPorts": false,
   402  			"RestartPolicy": {
   403  				"MaximumRetryCount": 2,
   404  				"Name": "on-failure"
   405  			},
   406  			"LogConfig": {
   407  				"Config": null,
   408  				"Type": "json-file"
   409  			},
   410  			"SecurityOpt": null,
   411  			"VolumesFrom": null,
   412  			"Ulimits": [{}]
   413  		},
   414  		"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
   415  		"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
   416  		"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
   417  		"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
   418  		"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
   419  		"MountLabel": "",
   420  		"Name": "/boring_euclid",
   421  		"NetworkSettings": {
   422  			"Bridge": "",
   423  			"Gateway": "",
   424  			"IPAddress": "",
   425  			"IPPrefixLen": 0,
   426  			"MacAddress": "",
   427  			"PortMapping": null,
   428  			"Ports": null
   429  		},
   430  		"Path": "/bin/sh",
   431  		"ProcessLabel": "",
   432  		"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
   433  		"RestartCount": 1,
   434  		"State": {
   435  			"Error": "",
   436  			"ExitCode": 9,
   437  			"FinishedAt": "2015-01-06T15:47:32.080254511Z",
   438  			"OOMKilled": false,
   439  			"Paused": false,
   440  			"Pid": 0,
   441  			"Restarting": false,
   442  			"Running": false,
   443  			"StartedAt": "2015-01-06T15:47:32.072697474Z"
   444  		},
   445  		"Mounts": [
   446  			{
   447  				"Source": "/data",
   448  				"Destination": "/data",
   449  				"Mode": "ro,Z",
   450  				"RW": false
   451  			}
   452  		]
   453  	}
   454  
   455  Status Codes:
   456  
   457  -   **200** – no error
   458  -   **404** – no such container
   459  -   **500** – server error
   460  
   461  ### List processes running inside a container
   462  
   463  `GET /containers/(id)/top`
   464  
   465  List processes running inside the container `id`. On Unix systems this
   466  is done by running the `ps` command. This endpoint is not
   467  supported on Windows.
   468  
   469  **Example request**:
   470  
   471      GET /containers/4fa6e0f0c678/top HTTP/1.1
   472  
   473  **Example response**:
   474  
   475      HTTP/1.1 200 OK
   476      Content-Type: application/json
   477  
   478      {
   479         "Titles" : [
   480           "UID", "PID", "PPID", "C", "STIME", "TTY", "TIME", "CMD"
   481         ],
   482         "Processes" : [
   483           [
   484             "root", "13642", "882", "0", "17:03", "pts/0", "00:00:00", "/bin/bash"
   485           ],
   486           [
   487             "root", "13735", "13642", "0", "17:06", "pts/0", "00:00:00", "sleep 10"
   488           ]
   489         ]
   490      }
   491  
   492  **Example request**:
   493  
   494      GET /containers/4fa6e0f0c678/top?ps_args=aux HTTP/1.1
   495  
   496  **Example response**:
   497  
   498      HTTP/1.1 200 OK
   499      Content-Type: application/json
   500  
   501      {
   502        "Titles" : [
   503          "USER","PID","%CPU","%MEM","VSZ","RSS","TTY","STAT","START","TIME","COMMAND"
   504        ]
   505        "Processes" : [
   506          [
   507            "root","13642","0.0","0.1","18172","3184","pts/0","Ss","17:03","0:00","/bin/bash"
   508          ],
   509          [
   510            "root","13895","0.0","0.0","4348","692","pts/0","S+","17:15","0:00","sleep 10"
   511          ]
   512        ],
   513      }
   514  
   515  Query Parameters:
   516  
   517  -   **ps_args** – `ps` arguments to use (e.g., `aux`), defaults to `-ef`
   518  
   519  Status Codes:
   520  
   521  -   **200** – no error
   522  -   **404** – no such container
   523  -   **500** – server error
   524  
   525  ### Get container logs
   526  
   527  `GET /containers/(id)/logs`
   528  
   529  Get `stdout` and `stderr` logs from the container ``id``
   530  
   531  > **Note**:
   532  > This endpoint works only for containers with the `json-file` or `journald` logging drivers.
   533  
   534  **Example request**:
   535  
   536       GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1
   537  
   538  **Example response**:
   539  
   540       HTTP/1.1 101 UPGRADED
   541       Content-Type: application/vnd.docker.raw-stream
   542       Connection: Upgrade
   543       Upgrade: tcp
   544  
   545       {{ STREAM }}
   546  
   547  Query Parameters:
   548  
   549  -   **follow** – 1/True/true or 0/False/false, return stream. Default `false`.
   550  -   **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`.
   551  -   **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`.
   552  -   **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
   553      will only output log-entries since that timestamp. Default: 0 (unfiltered)
   554  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   555          every log line. Default `false`.
   556  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
   557  
   558  Status Codes:
   559  
   560  -   **101** – no error, hints proxy about hijacking
   561  -   **200** – no error, no upgrade header found
   562  -   **404** – no such container
   563  -   **500** – server error
   564  
   565  ### Inspect changes on a container's filesystem
   566  
   567  `GET /containers/(id)/changes`
   568  
   569  Inspect changes on container `id`'s filesystem
   570  
   571  **Example request**:
   572  
   573      GET /containers/4fa6e0f0c678/changes HTTP/1.1
   574  
   575  **Example response**:
   576  
   577      HTTP/1.1 200 OK
   578      Content-Type: application/json
   579  
   580      [
   581           {
   582                   "Path": "/dev",
   583                   "Kind": 0
   584           },
   585           {
   586                   "Path": "/dev/kmsg",
   587                   "Kind": 1
   588           },
   589           {
   590                   "Path": "/test",
   591                   "Kind": 1
   592           }
   593      ]
   594  
   595  Values for `Kind`:
   596  
   597  - `0`: Modify
   598  - `1`: Add
   599  - `2`: Delete
   600  
   601  Status Codes:
   602  
   603  -   **200** – no error
   604  -   **404** – no such container
   605  -   **500** – server error
   606  
   607  ### Export a container
   608  
   609  `GET /containers/(id)/export`
   610  
   611  Export the contents of container `id`
   612  
   613  **Example request**:
   614  
   615      GET /containers/4fa6e0f0c678/export HTTP/1.1
   616  
   617  **Example response**:
   618  
   619      HTTP/1.1 200 OK
   620      Content-Type: application/octet-stream
   621  
   622      {{ TAR STREAM }}
   623  
   624  Status Codes:
   625  
   626  -   **200** – no error
   627  -   **404** – no such container
   628  -   **500** – server error
   629  
   630  ### Get container stats based on resource usage
   631  
   632  `GET /containers/(id)/stats`
   633  
   634  This endpoint returns a live stream of a container's resource usage statistics.
   635  
   636  **Example request**:
   637  
   638      GET /containers/redis1/stats HTTP/1.1
   639  
   640  **Example response**:
   641  
   642        HTTP/1.1 200 OK
   643        Content-Type: application/json
   644  
   645        {
   646           "read" : "2015-01-08T22:57:31.547920715Z",
   647           "network" : {
   648              "rx_dropped" : 0,
   649              "rx_bytes" : 648,
   650              "rx_errors" : 0,
   651              "tx_packets" : 8,
   652              "tx_dropped" : 0,
   653              "rx_packets" : 8,
   654              "tx_errors" : 0,
   655              "tx_bytes" : 648
   656           },
   657           "memory_stats" : {
   658              "stats" : {
   659                 "total_pgmajfault" : 0,
   660                 "cache" : 0,
   661                 "mapped_file" : 0,
   662                 "total_inactive_file" : 0,
   663                 "pgpgout" : 414,
   664                 "rss" : 6537216,
   665                 "total_mapped_file" : 0,
   666                 "writeback" : 0,
   667                 "unevictable" : 0,
   668                 "pgpgin" : 477,
   669                 "total_unevictable" : 0,
   670                 "pgmajfault" : 0,
   671                 "total_rss" : 6537216,
   672                 "total_rss_huge" : 6291456,
   673                 "total_writeback" : 0,
   674                 "total_inactive_anon" : 0,
   675                 "rss_huge" : 6291456,
   676                 "hierarchical_memory_limit" : 67108864,
   677                 "total_pgfault" : 964,
   678                 "total_active_file" : 0,
   679                 "active_anon" : 6537216,
   680                 "total_active_anon" : 6537216,
   681                 "total_pgpgout" : 414,
   682                 "total_cache" : 0,
   683                 "inactive_anon" : 0,
   684                 "active_file" : 0,
   685                 "pgfault" : 964,
   686                 "inactive_file" : 0,
   687                 "total_pgpgin" : 477
   688              },
   689              "max_usage" : 6651904,
   690              "usage" : 6537216,
   691              "failcnt" : 0,
   692              "limit" : 67108864
   693           },
   694           "blkio_stats" : {},
   695           "cpu_stats" : {
   696              "cpu_usage" : {
   697                 "percpu_usage" : [
   698                    16970827,
   699                    1839451,
   700                    7107380,
   701                    10571290
   702                 ],
   703                 "usage_in_usermode" : 10000000,
   704                 "total_usage" : 36488948,
   705                 "usage_in_kernelmode" : 20000000
   706              },
   707              "system_cpu_usage" : 20091722000000000,
   708              "throttling_data" : {}
   709           }
   710        }
   711  
   712  Query Parameters:
   713  
   714  -   **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
   715  
   716  Status Codes:
   717  
   718  -   **200** – no error
   719  -   **404** – no such container
   720  -   **500** – server error
   721  
   722  ### Resize a container TTY
   723  
   724  `POST /containers/(id)/resize?h=<height>&w=<width>`
   725  
   726  Resize the TTY for container with  `id`. You must restart the container for the resize to take effect.
   727  
   728  **Example request**:
   729  
   730        POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   731  
   732  **Example response**:
   733  
   734        HTTP/1.1 200 OK
   735        Content-Length: 0
   736        Content-Type: text/plain; charset=utf-8
   737  
   738  Status Codes:
   739  
   740  -   **200** – no error
   741  -   **404** – No such container
   742  -   **500** – Cannot resize container
   743  
   744  ### Start a container
   745  
   746  `POST /containers/(id)/start`
   747  
   748  Start the container `id`
   749  
   750  > **Note**:
   751  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   752  > See [create a container](#create-a-container) for details.
   753  
   754  **Example request**:
   755  
   756      POST /containers/(id)/start HTTP/1.1
   757  
   758  **Example response**:
   759  
   760      HTTP/1.1 204 No Content
   761  
   762  Status Codes:
   763  
   764  -   **204** – no error
   765  -   **304** – container already started
   766  -   **404** – no such container
   767  -   **500** – server error
   768  
   769  ### Stop a container
   770  
   771  `POST /containers/(id)/stop`
   772  
   773  Stop the container `id`
   774  
   775  **Example request**:
   776  
   777      POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   778  
   779  **Example response**:
   780  
   781      HTTP/1.1 204 No Content
   782  
   783  Query Parameters:
   784  
   785  -   **t** – number of seconds to wait before killing the container
   786  
   787  Status Codes:
   788  
   789  -   **204** – no error
   790  -   **304** – container already stopped
   791  -   **404** – no such container
   792  -   **500** – server error
   793  
   794  ### Restart a container
   795  
   796  `POST /containers/(id)/restart`
   797  
   798  Restart the container `id`
   799  
   800  **Example request**:
   801  
   802      POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   803  
   804  **Example response**:
   805  
   806      HTTP/1.1 204 No Content
   807  
   808  Query Parameters:
   809  
   810  -   **t** – number of seconds to wait before killing the container
   811  
   812  Status Codes:
   813  
   814  -   **204** – no error
   815  -   **404** – no such container
   816  -   **500** – server error
   817  
   818  ### Kill a container
   819  
   820  `POST /containers/(id)/kill`
   821  
   822  Kill the container `id`
   823  
   824  **Example request**:
   825  
   826      POST /containers/e90e34656806/kill HTTP/1.1
   827  
   828  **Example response**:
   829  
   830      HTTP/1.1 204 No Content
   831  
   832  Query Parameters
   833  
   834  -   **signal** - Signal to send to the container: integer or string like `SIGINT`.
   835          When not set, `SIGKILL` is assumed and the call waits for the container to exit.
   836  
   837  Status Codes:
   838  
   839  -   **204** – no error
   840  -   **404** – no such container
   841  -   **500** – server error
   842  
   843  ### Rename a container
   844  
   845  `POST /containers/(id)/rename`
   846  
   847  Rename the container `id` to a `new_name`
   848  
   849  **Example request**:
   850  
   851      POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
   852  
   853  **Example response**:
   854  
   855      HTTP/1.1 204 No Content
   856  
   857  Query Parameters:
   858  
   859  -   **name** – new name for the container
   860  
   861  Status Codes:
   862  
   863  -   **204** – no error
   864  -   **404** – no such container
   865  -   **409** - conflict name already assigned
   866  -   **500** – server error
   867  
   868  ### Pause a container
   869  
   870  `POST /containers/(id)/pause`
   871  
   872  Pause the container `id`
   873  
   874  **Example request**:
   875  
   876      POST /containers/e90e34656806/pause HTTP/1.1
   877  
   878  **Example response**:
   879  
   880      HTTP/1.1 204 No Content
   881  
   882  Status Codes:
   883  
   884  -   **204** – no error
   885  -   **404** – no such container
   886  -   **500** – server error
   887  
   888  ### Unpause a container
   889  
   890  `POST /containers/(id)/unpause`
   891  
   892  Unpause the container `id`
   893  
   894  **Example request**:
   895  
   896      POST /containers/e90e34656806/unpause HTTP/1.1
   897  
   898  **Example response**:
   899  
   900      HTTP/1.1 204 No Content
   901  
   902  Status Codes:
   903  
   904  -   **204** – no error
   905  -   **404** – no such container
   906  -   **500** – server error
   907  
   908  ### Attach to a container
   909  
   910  `POST /containers/(id)/attach`
   911  
   912  Attach to the container `id`
   913  
   914  **Example request**:
   915  
   916      POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   917  
   918  **Example response**:
   919  
   920      HTTP/1.1 101 UPGRADED
   921      Content-Type: application/vnd.docker.raw-stream
   922      Connection: Upgrade
   923      Upgrade: tcp
   924  
   925      {{ STREAM }}
   926  
   927  Query Parameters:
   928  
   929  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
   930  -   **stream** – 1/True/true or 0/False/false, return stream.
   931          Default `false`.
   932  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
   933          to `stdin`. Default `false`.
   934  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
   935          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
   936  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
   937          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
   938  
   939  Status Codes:
   940  
   941  -   **101** – no error, hints proxy about hijacking
   942  -   **200** – no error, no upgrade header found
   943  -   **400** – bad parameter
   944  -   **404** – no such container
   945  -   **500** – server error
   946  
   947      **Stream details**:
   948  
   949      When using the TTY setting is enabled in
   950      [`POST /containers/create`
   951      ](#create-a-container),
   952      the stream is the raw data from the process PTY and client's `stdin`.
   953      When the TTY is disabled, then the stream is multiplexed to separate
   954      `stdout` and `stderr`.
   955  
   956      The format is a **Header** and a **Payload** (frame).
   957  
   958      **HEADER**
   959  
   960      The header contains the information which the stream writes (`stdout` or
   961      `stderr`). It also contains the size of the associated frame encoded in the
   962      last four bytes (`uint32`).
   963  
   964      It is encoded on the first eight bytes like this:
   965  
   966          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   967  
   968      `STREAM_TYPE` can be:
   969  
   970  -   0: `stdin` (is written on `stdout`)
   971  -   1: `stdout`
   972  -   2: `stderr`
   973  
   974      `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
   975      the `uint32` size encoded as big endian.
   976  
   977      **PAYLOAD**
   978  
   979      The payload is the raw stream.
   980  
   981      **IMPLEMENTATION**
   982  
   983      The simplest way to implement the Attach protocol is the following:
   984  
   985      1.  Read eight bytes.
   986      2.  Choose `stdout` or `stderr` depending on the first byte.
   987      3.  Extract the frame size from the last four bytes.
   988      4.  Read the extracted size and output it on the correct output.
   989      5.  Goto 1.
   990  
   991  ### Attach to a container (websocket)
   992  
   993  `GET /containers/(id)/attach/ws`
   994  
   995  Attach to the container `id` via websocket
   996  
   997  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   998  
   999  **Example request**
  1000  
  1001      GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
  1002  
  1003  **Example response**
  1004  
  1005      {{ STREAM }}
  1006  
  1007  Query Parameters:
  1008  
  1009  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
  1010  -   **stream** – 1/True/true or 0/False/false, return stream.
  1011          Default `false`.
  1012  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
  1013          to `stdin`. Default `false`.
  1014  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
  1015          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
  1016  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
  1017          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
  1018  
  1019  Status Codes:
  1020  
  1021  -   **200** – no error
  1022  -   **400** – bad parameter
  1023  -   **404** – no such container
  1024  -   **500** – server error
  1025  
  1026  ### Wait a container
  1027  
  1028  `POST /containers/(id)/wait`
  1029  
  1030  Block until container `id` stops, then returns the exit code
  1031  
  1032  **Example request**:
  1033  
  1034      POST /containers/16253994b7c4/wait HTTP/1.1
  1035  
  1036  **Example response**:
  1037  
  1038      HTTP/1.1 200 OK
  1039      Content-Type: application/json
  1040  
  1041      {"StatusCode": 0}
  1042  
  1043  Status Codes:
  1044  
  1045  -   **200** – no error
  1046  -   **404** – no such container
  1047  -   **500** – server error
  1048  
  1049  ### Remove a container
  1050  
  1051  `DELETE /containers/(id)`
  1052  
  1053  Remove the container `id` from the filesystem
  1054  
  1055  **Example request**:
  1056  
  1057      DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  1058  
  1059  **Example response**:
  1060  
  1061      HTTP/1.1 204 No Content
  1062  
  1063  Query Parameters:
  1064  
  1065  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1066          associated to the container. Default `false`.
  1067  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1068          Default `false`.
  1069  
  1070  Status Codes:
  1071  
  1072  -   **204** – no error
  1073  -   **400** – bad parameter
  1074  -   **404** – no such container
  1075  -   **500** – server error
  1076  
  1077  ### Copy files or folders from a container
  1078  
  1079  `POST /containers/(id)/copy`
  1080  
  1081  Copy files or folders of container `id`
  1082  
  1083  **Deprecated** in favor of the `archive` endpoint below.
  1084  
  1085  **Example request**:
  1086  
  1087      POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1088      Content-Type: application/json
  1089  
  1090      {
  1091           "Resource": "test.txt"
  1092      }
  1093  
  1094  **Example response**:
  1095  
  1096      HTTP/1.1 200 OK
  1097      Content-Type: application/x-tar
  1098  
  1099      {{ TAR STREAM }}
  1100  
  1101  Status Codes:
  1102  
  1103  -   **200** – no error
  1104  -   **404** – no such container
  1105  -   **500** – server error
  1106  
  1107  ### Retrieving information about files and folders in a container
  1108  
  1109  `HEAD /containers/(id)/archive`
  1110  
  1111  See the description of the `X-Docker-Container-Path-Stat` header in the
  1112  following section.
  1113  
  1114  ### Get an archive of a filesystem resource in a container
  1115  
  1116  `GET /containers/(id)/archive`
  1117  
  1118  Get an tar archive of a resource in the filesystem of container `id`.
  1119  
  1120  Query Parameters:
  1121  
  1122  - **path** - resource in the container's filesystem to archive. Required.
  1123  
  1124      If not an absolute path, it is relative to the container's root directory.
  1125      The resource specified by **path** must exist. To assert that the resource
  1126      is expected to be a directory, **path** should end in `/` or  `/.`
  1127      (assuming a path separator of `/`). If **path** ends in `/.` then this
  1128      indicates that only the contents of the **path** directory should be
  1129      copied. A symlink is always resolved to its target.
  1130  
  1131      **Note**: It is not possible to copy certain system files such as resources
  1132      under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
  1133      container.
  1134  
  1135  **Example request**:
  1136  
  1137          GET /containers/8cce319429b2/archive?path=/root HTTP/1.1
  1138  
  1139  **Example response**:
  1140  
  1141          HTTP/1.1 200 OK
  1142          Content-Type: application/x-tar
  1143          X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
  1144  
  1145          {{ TAR STREAM }}
  1146  
  1147  On success, a response header `X-Docker-Container-Path-Stat` will be set to a
  1148  base64-encoded JSON object containing some filesystem header information about
  1149  the archived resource. The above example value would decode to the following
  1150  JSON object (whitespace added for readability):
  1151  
  1152          {
  1153              "name": "root",
  1154              "size": 4096,
  1155              "mode": 2147484096,
  1156              "mtime": "2014-02-27T20:51:23Z",
  1157              "linkTarget": ""
  1158          }
  1159  
  1160  A `HEAD` request can also be made to this endpoint if only this information is
  1161  desired.
  1162  
  1163  Status Codes:
  1164  
  1165  - **200** - success, returns archive of copied resource
  1166  - **400** - client error, bad parameter, details in JSON response body, one of:
  1167      - must specify path parameter (**path** cannot be empty)
  1168      - not a directory (**path** was asserted to be a directory but exists as a
  1169        file)
  1170  - **404** - client error, resource not found, one of:
  1171      – no such container (container `id` does not exist)
  1172      - no such file or directory (**path** does not exist)
  1173  - **500** - server error
  1174  
  1175  ### Extract an archive of files or folders to a directory in a container
  1176  
  1177  `PUT /containers/(id)/archive`
  1178  
  1179  Upload a tar archive to be extracted to a path in the filesystem of container
  1180  `id`.
  1181  
  1182  Query Parameters:
  1183  
  1184  - **path** - path to a directory in the container
  1185      to extract the archive's contents into. Required.
  1186  
  1187      If not an absolute path, it is relative to the container's root directory.
  1188      The **path** resource must exist.
  1189  - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error
  1190      if unpacking the given content would cause an existing directory to be
  1191      replaced with a non-directory and vice versa.
  1192  
  1193  **Example request**:
  1194  
  1195          PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
  1196          Content-Type: application/x-tar
  1197  
  1198          {{ TAR STREAM }}
  1199  
  1200  **Example response**:
  1201  
  1202          HTTP/1.1 200 OK
  1203  
  1204  Status Codes:
  1205  
  1206  - **200** – the content was extracted successfully
  1207  - **400** - client error, bad parameter, details in JSON response body, one of:
  1208      - must specify path parameter (**path** cannot be empty)
  1209      - not a directory (**path** should be a directory but exists as a file)
  1210      - unable to overwrite existing directory with non-directory
  1211        (if **noOverwriteDirNonDir**)
  1212      - unable to overwrite existing non-directory with directory
  1213        (if **noOverwriteDirNonDir**)
  1214  - **403** - client error, permission denied, the volume
  1215      or container rootfs is marked as read-only.
  1216  - **404** - client error, resource not found, one of:
  1217      – no such container (container `id` does not exist)
  1218      - no such file or directory (**path** resource does not exist)
  1219  - **500** – server error
  1220  
  1221  ## 2.2 Images
  1222  
  1223  ### List Images
  1224  
  1225  `GET /images/json`
  1226  
  1227  **Example request**:
  1228  
  1229      GET /images/json?all=0 HTTP/1.1
  1230  
  1231  **Example response**:
  1232  
  1233      HTTP/1.1 200 OK
  1234      Content-Type: application/json
  1235  
  1236      [
  1237        {
  1238           "RepoTags": [
  1239             "ubuntu:12.04",
  1240             "ubuntu:precise",
  1241             "ubuntu:latest"
  1242           ],
  1243           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1244           "Created": 1365714795,
  1245           "Size": 131506275,
  1246           "VirtualSize": 131506275,
  1247           "Labels": {}
  1248        },
  1249        {
  1250           "RepoTags": [
  1251             "ubuntu:12.10",
  1252             "ubuntu:quantal"
  1253           ],
  1254           "ParentId": "27cf784147099545",
  1255           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1256           "Created": 1364102658,
  1257           "Size": 24653,
  1258           "VirtualSize": 180116135,
  1259           "Labels": {
  1260              "com.example.version": "v1"
  1261           }
  1262        }
  1263      ]
  1264  
  1265  **Example request, with digest information**:
  1266  
  1267      GET /images/json?digests=1 HTTP/1.1
  1268  
  1269  **Example response, with digest information**:
  1270  
  1271      HTTP/1.1 200 OK
  1272      Content-Type: application/json
  1273  
  1274      [
  1275        {
  1276          "Created": 1420064636,
  1277          "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1278          "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1279          "RepoDigests": [
  1280            "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1281          ],
  1282          "RepoTags": [
  1283            "localhost:5000/test/busybox:latest",
  1284            "playdate:latest"
  1285          ],
  1286          "Size": 0,
  1287          "VirtualSize": 2429728,
  1288          "Labels": {}
  1289        }
  1290      ]
  1291  
  1292  The response shows a single image `Id` associated with two repositories
  1293  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1294  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1295  `playdate:latest` to reference the image.
  1296  
  1297  You can also use `RepoDigests` values to reference an image. In this response,
  1298  the array has only one reference and that is to the
  1299  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1300  digest. You can reference this digest using the value:
  1301  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1302  
  1303  See the `docker run` and `docker build` commands for examples of digest and tag
  1304  references on the command line.
  1305  
  1306  Query Parameters:
  1307  
  1308  -   **all** – 1/True/true or 0/False/false, default false
  1309  -   **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1310    -   `dangling=true`
  1311    -   `label=key` or `label="key=value"` of an image label
  1312  -   **filter** - only return images with the specified name
  1313  
  1314  ### Build image from a Dockerfile
  1315  
  1316  `POST /build`
  1317  
  1318  Build an image from a Dockerfile
  1319  
  1320  **Example request**:
  1321  
  1322      POST /build HTTP/1.1
  1323  
  1324      {{ TAR STREAM }}
  1325  
  1326  **Example response**:
  1327  
  1328      HTTP/1.1 200 OK
  1329      Content-Type: application/json
  1330  
  1331      {"stream": "Step 1..."}
  1332      {"stream": "..."}
  1333      {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1334  
  1335  The input stream must be a `tar` archive compressed with one of the
  1336  following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
  1337  
  1338  The archive must include a build instructions file, typically called
  1339  `Dockerfile` at the archive's root. The `dockerfile` parameter may be
  1340  used to specify a different build instructions file. To do this, its value must be
  1341  the path to the alternate build instructions file to use.
  1342  
  1343  The archive may include any number of other files,
  1344  which are accessible in the build context (See the [*ADD build
  1345  command*](../../reference/builder.md#dockerbuilder)).
  1346  
  1347  The build is canceled if the client drops the connection by quitting
  1348  or being killed.
  1349  
  1350  Query Parameters:
  1351  
  1352  -   **dockerfile** - Path within the build context to the Dockerfile. This is 
  1353          ignored if `remote` is specified and points to an individual filename.
  1354  -   **t** – A repository name (and optionally a tag) to apply to
  1355          the resulting image in case of success.
  1356  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 
  1357          URI specifies a filename, the file's contents are placed into a file 
  1358  		called `Dockerfile`.
  1359  -   **q** – Suppress verbose build output.
  1360  -   **nocache** – Do not use the cache when building the image.
  1361  -   **pull** - Attempt to pull the image even if an older image exists locally.
  1362  -   **rm** - Remove intermediate containers after a successful build (default behavior).
  1363  -   **forcerm** - Always remove intermediate containers (includes `rm`).
  1364  -   **memory** - Set memory limit for build.
  1365  -   **memswap** - Total memory (memory + swap), `-1` to disable swap.
  1366  -   **cpushares** - CPU shares (relative weight).
  1367  -   **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
  1368  -   **cpuperiod** - The length of a CPU period in microseconds.
  1369  -   **cpuquota** - Microseconds of CPU time that the container can get in a CPU period.
  1370  
  1371      Request Headers:
  1372  
  1373  -   **Content-type** – Set to `"application/tar"`.
  1374  -   **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
  1375          object with the following structure:
  1376  
  1377              {
  1378                  "docker.example.com": {
  1379                      "username": "janedoe",
  1380                      "password": "hunter2"
  1381                  },
  1382                  "https://index.docker.io/v1/": {
  1383                      "username": "mobydock",
  1384                      "password": "conta1n3rize14"
  1385                  }
  1386              }
  1387  
  1388          This object maps the hostname of a registry to an object containing the
  1389          "username" and "password" for that registry. Multiple registries may
  1390          be specified as the build may be based on an image requiring
  1391          authentication to pull from any arbitrary registry. Only the registry
  1392          domain name (and port if not the default "443") are required. However
  1393          (for legacy reasons) the "official" Docker, Inc. hosted registry must
  1394          be specified with both a "https://" prefix and a "/v1/" suffix even
  1395          though Docker will prefer to use the v2 registry API.
  1396  
  1397  Status Codes:
  1398  
  1399  -   **200** – no error
  1400  -   **500** – server error
  1401  
  1402  ### Create an image
  1403  
  1404  `POST /images/create`
  1405  
  1406  Create an image either by pulling it from the registry or by importing it
  1407  
  1408  **Example request**:
  1409  
  1410      POST /images/create?fromImage=ubuntu HTTP/1.1
  1411  
  1412  **Example response**:
  1413  
  1414      HTTP/1.1 200 OK
  1415      Content-Type: application/json
  1416  
  1417      {"status": "Pulling..."}
  1418      {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1419      {"error": "Invalid..."}
  1420      ...
  1421  
  1422  When using this endpoint to pull an image from the registry, the
  1423  `X-Registry-Auth` header can be used to include
  1424  a base64-encoded AuthConfig object.
  1425  
  1426  Query Parameters:
  1427  
  1428  -   **fromImage** – Name of the image to pull.
  1429  -   **fromSrc** – Source to import.  The value may be a URL from which the image
  1430          can be retrieved or `-` to read the image from the request body.
  1431  -   **repo** – Repository name.
  1432  -   **tag** – Tag.
  1433  -   **registry** – The registry to pull from.
  1434  
  1435      Request Headers:
  1436  
  1437  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1438  
  1439  Status Codes:
  1440  
  1441  -   **200** – no error
  1442  -   **500** – server error
  1443  
  1444  
  1445  
  1446  ### Inspect an image
  1447  
  1448  `GET /images/(name)/json`
  1449  
  1450  Return low-level information on the image `name`
  1451  
  1452  **Example request**:
  1453  
  1454      GET /images/ubuntu/json HTTP/1.1
  1455  
  1456  **Example response**:
  1457  
  1458      HTTP/1.1 200 OK
  1459      Content-Type: application/json
  1460  
  1461      {
  1462           "Created": "2013-03-23T22:24:18.818426-07:00",
  1463           "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1464           "ContainerConfig":
  1465                   {
  1466                           "Hostname": "",
  1467                           "User": "",
  1468                           "AttachStdin": false,
  1469                           "AttachStdout": false,
  1470                           "AttachStderr": false,
  1471                           "Tty": true,
  1472                           "OpenStdin": true,
  1473                           "StdinOnce": false,
  1474                           "Env": null,
  1475                           "Cmd": ["/bin/bash"],
  1476                           "Dns": null,
  1477                           "Image": "ubuntu",
  1478                           "Labels": {
  1479                               "com.example.vendor": "Acme",
  1480                               "com.example.license": "GPL",
  1481                               "com.example.version": "1.0"
  1482                           },
  1483                           "Volumes": null,
  1484                           "VolumesFrom": "",
  1485                           "WorkingDir": ""
  1486                   },
  1487           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1488           "Parent": "27cf784147099545",
  1489           "Size": 6824592
  1490      }
  1491  
  1492  Status Codes:
  1493  
  1494  -   **200** – no error
  1495  -   **404** – no such image
  1496  -   **500** – server error
  1497  
  1498  ### Get the history of an image
  1499  
  1500  `GET /images/(name)/history`
  1501  
  1502  Return the history of the image `name`
  1503  
  1504  **Example request**:
  1505  
  1506      GET /images/ubuntu/history HTTP/1.1
  1507  
  1508  **Example response**:
  1509  
  1510      HTTP/1.1 200 OK
  1511      Content-Type: application/json
  1512  
  1513      [
  1514          {
  1515              "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
  1516              "Created": 1398108230,
  1517              "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
  1518              "Tags": [
  1519                  "ubuntu:lucid",
  1520                  "ubuntu:10.04"
  1521              ],
  1522              "Size": 182964289,
  1523              "Comment": ""
  1524          },
  1525          {
  1526              "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
  1527              "Created": 1398108222,
  1528              "CreatedBy": "/bin/sh -c #(nop) MAINTAINER Tianon Gravi <admwiggin@gmail.com> - mkimage-debootstrap.sh -i iproute,iputils-ping,ubuntu-minimal -t lucid.tar.xz lucid http://archive.ubuntu.com/ubuntu/",
  1529              "Tags": null,
  1530              "Size": 0,
  1531              "Comment": ""
  1532          },
  1533          {
  1534              "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
  1535              "Created": 1371157430,
  1536              "CreatedBy": "",
  1537              "Tags": [
  1538                  "scratch12:latest",
  1539                  "scratch:latest"
  1540              ],
  1541              "Size": 0,
  1542              "Comment": "Imported from -"
  1543          }
  1544      ]
  1545  
  1546  Status Codes:
  1547  
  1548  -   **200** – no error
  1549  -   **404** – no such image
  1550  -   **500** – server error
  1551  
  1552  ### Push an image on the registry
  1553  
  1554  `POST /images/(name)/push`
  1555  
  1556  Push the image `name` on the registry
  1557  
  1558  **Example request**:
  1559  
  1560      POST /images/test/push HTTP/1.1
  1561  
  1562  **Example response**:
  1563  
  1564      HTTP/1.1 200 OK
  1565      Content-Type: application/json
  1566  
  1567      {"status": "Pushing..."}
  1568      {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1569      {"error": "Invalid..."}
  1570      ...
  1571  
  1572  If you wish to push an image on to a private registry, that image must already have a tag
  1573  into a repository which references that registry `hostname` and `port`.  This repository name should
  1574  then be used in the URL. This duplicates the command line's flow.
  1575  
  1576  **Example request**:
  1577  
  1578      POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1579  
  1580  
  1581  Query Parameters:
  1582  
  1583  -   **tag** – The tag to associate with the image on the registry. This is optional.
  1584  
  1585  Request Headers:
  1586  
  1587  -   **X-Registry-Auth** – Include a base64-encoded AuthConfig.
  1588          object.
  1589  
  1590  Status Codes:
  1591  
  1592  -   **200** – no error
  1593  -   **404** – no such image
  1594  -   **500** – server error
  1595  
  1596  ### Tag an image into a repository
  1597  
  1598  `POST /images/(name)/tag`
  1599  
  1600  Tag the image `name` into a repository
  1601  
  1602  **Example request**:
  1603  
  1604      POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1605  
  1606  **Example response**:
  1607  
  1608      HTTP/1.1 201 OK
  1609  
  1610  Query Parameters:
  1611  
  1612  -   **repo** – The repository to tag in
  1613  -   **force** – 1/True/true or 0/False/false, default false
  1614  -   **tag** - The new tag name
  1615  
  1616  Status Codes:
  1617  
  1618  -   **201** – no error
  1619  -   **400** – bad parameter
  1620  -   **404** – no such image
  1621  -   **409** – conflict
  1622  -   **500** – server error
  1623  
  1624  ### Remove an image
  1625  
  1626  `DELETE /images/(name)`
  1627  
  1628  Remove the image `name` from the filesystem
  1629  
  1630  **Example request**:
  1631  
  1632      DELETE /images/test HTTP/1.1
  1633  
  1634  **Example response**:
  1635  
  1636      HTTP/1.1 200 OK
  1637      Content-type: application/json
  1638  
  1639      [
  1640       {"Untagged": "3e2f21a89f"},
  1641       {"Deleted": "3e2f21a89f"},
  1642       {"Deleted": "53b4f83ac9"}
  1643      ]
  1644  
  1645  Query Parameters:
  1646  
  1647  -   **force** – 1/True/true or 0/False/false, default false
  1648  -   **noprune** – 1/True/true or 0/False/false, default false
  1649  
  1650  Status Codes:
  1651  
  1652  -   **200** – no error
  1653  -   **404** – no such image
  1654  -   **409** – conflict
  1655  -   **500** – server error
  1656  
  1657  ### Search images
  1658  
  1659  `GET /images/search`
  1660  
  1661  Search for an image on [Docker Hub](https://hub.docker.com).
  1662  
  1663  > **Note**:
  1664  > The response keys have changed from API v1.6 to reflect the JSON
  1665  > sent by the registry server to the docker daemon's request.
  1666  
  1667  **Example request**:
  1668  
  1669      GET /images/search?term=sshd HTTP/1.1
  1670  
  1671  **Example response**:
  1672  
  1673      HTTP/1.1 200 OK
  1674      Content-Type: application/json
  1675  
  1676      [
  1677              {
  1678                  "description": "",
  1679                  "is_official": false,
  1680                  "is_automated": false,
  1681                  "name": "wma55/u1210sshd",
  1682                  "star_count": 0
  1683              },
  1684              {
  1685                  "description": "",
  1686                  "is_official": false,
  1687                  "is_automated": false,
  1688                  "name": "jdswinbank/sshd",
  1689                  "star_count": 0
  1690              },
  1691              {
  1692                  "description": "",
  1693                  "is_official": false,
  1694                  "is_automated": false,
  1695                  "name": "vgauthier/sshd",
  1696                  "star_count": 0
  1697              }
  1698      ...
  1699      ]
  1700  
  1701  Query Parameters:
  1702  
  1703  -   **term** – term to search
  1704  
  1705  Status Codes:
  1706  
  1707  -   **200** – no error
  1708  -   **500** – server error
  1709  
  1710  ## 2.3 Misc
  1711  
  1712  ### Check auth configuration
  1713  
  1714  `POST /auth`
  1715  
  1716  Get the default username and email
  1717  
  1718  **Example request**:
  1719  
  1720      POST /auth HTTP/1.1
  1721      Content-Type: application/json
  1722  
  1723      {
  1724           "username":" hannibal",
  1725           "password: "xxxx",
  1726           "email": "hannibal@a-team.com",
  1727           "serveraddress": "https://index.docker.io/v1/"
  1728      }
  1729  
  1730  **Example response**:
  1731  
  1732      HTTP/1.1 200 OK
  1733  
  1734  Status Codes:
  1735  
  1736  -   **200** – no error
  1737  -   **204** – no error
  1738  -   **500** – server error
  1739  
  1740  ### Display system-wide information
  1741  
  1742  `GET /info`
  1743  
  1744  Display system-wide information
  1745  
  1746  **Example request**:
  1747  
  1748      GET /info HTTP/1.1
  1749  
  1750  **Example response**:
  1751  
  1752      HTTP/1.1 200 OK
  1753      Content-Type: application/json
  1754  
  1755      {
  1756          "Containers": 11,
  1757          "CpuCfsPeriod": true,
  1758          "CpuCfsQuota": true,
  1759          "Debug": false,
  1760          "DockerRootDir": "/var/lib/docker",
  1761          "Driver": "btrfs",
  1762          "DriverStatus": [[""]],
  1763          "ExecutionDriver": "native-0.1",
  1764          "ExperimentalBuild": false,
  1765          "HttpProxy": "http://test:test@localhost:8080",
  1766          "HttpsProxy": "https://test:test@localhost:8080",
  1767          "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1768          "IPv4Forwarding": true,
  1769          "Images": 16,
  1770          "IndexServerAddress": "https://index.docker.io/v1/",
  1771          "InitPath": "/usr/bin/docker",
  1772          "InitSha1": "",
  1773          "KernelVersion": "3.12.0-1-amd64",
  1774          "Labels": [
  1775              "storage=ssd"
  1776          ],
  1777          "MemTotal": 2099236864,
  1778          "MemoryLimit": true,
  1779          "NCPU": 1,
  1780          "NEventsListener": 0,
  1781          "NFd": 11,
  1782          "NGoroutines": 21,
  1783          "Name": "prod-server-42",
  1784          "NoProxy": "9.81.1.160",
  1785          "OomKillDisable": true,
  1786          "OperatingSystem": "Boot2Docker",
  1787          "RegistryConfig": {
  1788              "IndexConfigs": {
  1789                  "docker.io": {
  1790                      "Mirrors": null,
  1791                      "Name": "docker.io",
  1792                      "Official": true,
  1793                      "Secure": true
  1794                  }
  1795              },
  1796              "InsecureRegistryCIDRs": [
  1797                  "127.0.0.0/8"
  1798              ]
  1799          },
  1800          "SwapLimit": false,
  1801          "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1802      }
  1803  
  1804  Status Codes:
  1805  
  1806  -   **200** – no error
  1807  -   **500** – server error
  1808  
  1809  ### Show the docker version information
  1810  
  1811  `GET /version`
  1812  
  1813  Show the docker version information
  1814  
  1815  **Example request**:
  1816  
  1817      GET /version HTTP/1.1
  1818  
  1819  **Example response**:
  1820  
  1821      HTTP/1.1 200 OK
  1822      Content-Type: application/json
  1823  
  1824      {
  1825           "Version": "1.5.0",
  1826           "Os": "linux",
  1827           "KernelVersion": "3.18.5-tinycore64",
  1828           "GoVersion": "go1.4.1",
  1829           "GitCommit": "a8a31ef",
  1830           "Arch": "amd64",
  1831           "ApiVersion": "1.20",
  1832           "Experimental": false
  1833      }
  1834  
  1835  Status Codes:
  1836  
  1837  -   **200** – no error
  1838  -   **500** – server error
  1839  
  1840  ### Ping the docker server
  1841  
  1842  `GET /_ping`
  1843  
  1844  Ping the docker server
  1845  
  1846  **Example request**:
  1847  
  1848      GET /_ping HTTP/1.1
  1849  
  1850  **Example response**:
  1851  
  1852      HTTP/1.1 200 OK
  1853      Content-Type: text/plain
  1854  
  1855      OK
  1856  
  1857  Status Codes:
  1858  
  1859  -   **200** - no error
  1860  -   **500** - server error
  1861  
  1862  ### Create a new image from a container's changes
  1863  
  1864  `POST /commit`
  1865  
  1866  Create a new image from a container's changes
  1867  
  1868  **Example request**:
  1869  
  1870      POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1871      Content-Type: application/json
  1872  
  1873      {
  1874           "Hostname": "",
  1875           "Domainname": "",
  1876           "User": "",
  1877           "AttachStdin": false,
  1878           "AttachStdout": true,
  1879           "AttachStderr": true,
  1880           "Tty": false,
  1881           "OpenStdin": false,
  1882           "StdinOnce": false,
  1883           "Env": null,
  1884           "Cmd": [
  1885                   "date"
  1886           ],
  1887           "Mounts": [
  1888             {
  1889               "Source": "/data",
  1890               "Destination": "/data",
  1891               "Mode": "ro,Z",
  1892               "RW": false
  1893             }
  1894           ],
  1895           "Labels": {
  1896                   "key1": "value1",
  1897                   "key2": "value2"
  1898            },
  1899           "WorkingDir": "",
  1900           "NetworkDisabled": false,
  1901           "ExposedPorts": {
  1902                   "22/tcp": {}
  1903           }
  1904      }
  1905  
  1906  **Example response**:
  1907  
  1908      HTTP/1.1 201 Created
  1909      Content-Type: application/json
  1910  
  1911      {"Id": "596069db4bf5"}
  1912  
  1913  Json Parameters:
  1914  
  1915  -  **config** - the container's configuration
  1916  
  1917  Query Parameters:
  1918  
  1919  -   **container** – source container
  1920  -   **repo** – repository
  1921  -   **tag** – tag
  1922  -   **comment** – commit message
  1923  -   **author** – author (e.g., "John Hannibal Smith
  1924      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1925  -   **pause** – 1/True/true or 0/False/false, whether to pause the container before committing
  1926  -   **changes** – Dockerfile instructions to apply while committing
  1927  
  1928  Status Codes:
  1929  
  1930  -   **201** – no error
  1931  -   **404** – no such container
  1932  -   **500** – server error
  1933  
  1934  ### Monitor Docker's events
  1935  
  1936  `GET /events`
  1937  
  1938  Get container events from docker, either in real time via streaming, or via
  1939  polling (using since).
  1940  
  1941  Docker containers report the following events:
  1942  
  1943      attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause
  1944  
  1945  and Docker images report:
  1946  
  1947      delete, import, pull, push, tag, untag
  1948  
  1949  **Example request**:
  1950  
  1951      GET /events?since=1374067924
  1952  
  1953  **Example response**:
  1954  
  1955      HTTP/1.1 200 OK
  1956      Content-Type: application/json
  1957  
  1958      {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1959      {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1960      {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1961      {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1962  
  1963  Query Parameters:
  1964  
  1965  -   **since** – Timestamp used for polling
  1966  -   **until** – Timestamp used for polling
  1967  -   **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1968    -   `event=<string>`; -- event to filter
  1969    -   `image=<string>`; -- image to filter
  1970    -   `container=<string>`; -- container to filter
  1971  
  1972  Status Codes:
  1973  
  1974  -   **200** – no error
  1975  -   **500** – server error
  1976  
  1977  ### Get a tarball containing all images in a repository
  1978  
  1979  `GET /images/(name)/get`
  1980  
  1981  Get a tarball containing all images and metadata for the repository specified
  1982  by `name`.
  1983  
  1984  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1985  (and its parents) are returned. If `name` is an image ID, similarly only that
  1986  image (and its parents) are returned, but with the exclusion of the
  1987  'repositories' file in the tarball, as there were no image names referenced.
  1988  
  1989  See the [image tarball format](#image-tarball-format) for more details.
  1990  
  1991  **Example request**
  1992  
  1993      GET /images/ubuntu/get
  1994  
  1995  **Example response**:
  1996  
  1997      HTTP/1.1 200 OK
  1998      Content-Type: application/x-tar
  1999  
  2000      Binary data stream
  2001  
  2002  Status Codes:
  2003  
  2004  -   **200** – no error
  2005  -   **500** – server error
  2006  
  2007  ### Get a tarball containing all images.
  2008  
  2009  `GET /images/get`
  2010  
  2011  Get a tarball containing all images and metadata for one or more repositories.
  2012  
  2013  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  2014  `ubuntu:latest`), then only that image (and its parents) are returned; if it is
  2015  an image ID, similarly only that image (and its parents) are returned and there
  2016  would be no names referenced in the 'repositories' file for this image ID.
  2017  
  2018  See the [image tarball format](#image-tarball-format) for more details.
  2019  
  2020  **Example request**
  2021  
  2022      GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  2023  
  2024  **Example response**:
  2025  
  2026      HTTP/1.1 200 OK
  2027      Content-Type: application/x-tar
  2028  
  2029      Binary data stream
  2030  
  2031  Status Codes:
  2032  
  2033  -   **200** – no error
  2034  -   **500** – server error
  2035  
  2036  ### Load a tarball with a set of images and tags into docker
  2037  
  2038  `POST /images/load`
  2039  
  2040  Load a set of images and tags into a Docker repository.
  2041  See the [image tarball format](#image-tarball-format) for more details.
  2042  
  2043  **Example request**
  2044  
  2045      POST /images/load
  2046  
  2047      Tarball in body
  2048  
  2049  **Example response**:
  2050  
  2051      HTTP/1.1 200 OK
  2052  
  2053  Status Codes:
  2054  
  2055  -   **200** – no error
  2056  -   **500** – server error
  2057  
  2058  ### Image tarball format
  2059  
  2060  An image tarball contains one directory per image layer (named using its long ID),
  2061  each containing these files:
  2062  
  2063  - `VERSION`: currently `1.0` - the file format version
  2064  - `json`: detailed layer information, similar to `docker inspect layer_id`
  2065  - `layer.tar`: A tarfile containing the filesystem changes in this layer
  2066  
  2067  The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
  2068  for storing attribute changes and deletions.
  2069  
  2070  If the tarball defines a repository, the tarball should also include a `repositories` file at
  2071  the root that contains a list of repository and tag names mapped to layer IDs.
  2072  
  2073  ```
  2074  {"hello-world":
  2075      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  2076  }
  2077  ```
  2078  
  2079  ### Exec Create
  2080  
  2081  `POST /containers/(id)/exec`
  2082  
  2083  Sets up an exec instance in a running container `id`
  2084  
  2085  **Example request**:
  2086  
  2087      POST /containers/e90e34656806/exec HTTP/1.1
  2088      Content-Type: application/json
  2089  
  2090        {
  2091         "AttachStdin": false,
  2092         "AttachStdout": true,
  2093         "AttachStderr": true,
  2094         "Tty": false,
  2095         "Cmd": [
  2096                       "date"
  2097               ]
  2098        }
  2099  
  2100  **Example response**:
  2101  
  2102      HTTP/1.1 201 OK
  2103      Content-Type: application/json
  2104  
  2105      {
  2106           "Id": "f90e34656806",
  2107           "Warnings":[]
  2108      }
  2109  
  2110  Json Parameters:
  2111  
  2112  -   **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
  2113  -   **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
  2114  -   **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
  2115  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2116  -   **Cmd** - Command to run specified as a string or an array of strings.
  2117  
  2118  
  2119  Status Codes:
  2120  
  2121  -   **201** – no error
  2122  -   **404** – no such container
  2123  
  2124  ### Exec Start
  2125  
  2126  `POST /exec/(id)/start`
  2127  
  2128  Starts a previously set up `exec` instance `id`. If `detach` is true, this API
  2129  returns after starting the `exec` command. Otherwise, this API sets up an
  2130  interactive session with the `exec` command.
  2131  
  2132  **Example request**:
  2133  
  2134      POST /exec/e90e34656806/start HTTP/1.1
  2135      Content-Type: application/json
  2136  
  2137      {
  2138       "Detach": false,
  2139       "Tty": false
  2140      }
  2141  
  2142  **Example response**:
  2143  
  2144      HTTP/1.1 201 OK
  2145      Content-Type: application/json
  2146  
  2147      {{ STREAM }}
  2148  
  2149  Json Parameters:
  2150  
  2151  -   **Detach** - Detach from the `exec` command.
  2152  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2153  
  2154  Status Codes:
  2155  
  2156  -   **200** – no error
  2157  -   **404** – no such exec instance
  2158  
  2159      **Stream details**:
  2160      Similar to the stream behavior of `POST /container/(id)/attach` API
  2161  
  2162  ### Exec Resize
  2163  
  2164  `POST /exec/(id)/resize`
  2165  
  2166  Resizes the `tty` session used by the `exec` command `id`.  The unit is number of characters.
  2167  This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
  2168  
  2169  **Example request**:
  2170  
  2171      POST /exec/e90e34656806/resize?h=40&w=80 HTTP/1.1
  2172      Content-Type: text/plain
  2173  
  2174  **Example response**:
  2175  
  2176      HTTP/1.1 201 OK
  2177      Content-Type: text/plain
  2178  
  2179  Query Parameters:
  2180  
  2181  -   **h** – height of `tty` session
  2182  -   **w** – width
  2183  
  2184  Status Codes:
  2185  
  2186  -   **201** – no error
  2187  -   **404** – no such exec instance
  2188  
  2189  ### Exec Inspect
  2190  
  2191  `GET /exec/(id)/json`
  2192  
  2193  Return low-level information about the `exec` command `id`.
  2194  
  2195  **Example request**:
  2196  
  2197      GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  2198  
  2199  **Example response**:
  2200  
  2201      HTTP/1.1 200 OK
  2202      Content-Type: plain/text
  2203  
  2204      {
  2205        "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  2206        "Running" : false,
  2207        "ExitCode" : 2,
  2208        "ProcessConfig" : {
  2209          "privileged" : false,
  2210          "user" : "",
  2211          "tty" : false,
  2212          "entrypoint" : "sh",
  2213          "arguments" : [
  2214            "-c",
  2215            "exit 2"
  2216          ]
  2217        },
  2218        "OpenStdin" : false,
  2219        "OpenStderr" : false,
  2220        "OpenStdout" : false,
  2221        "Container" : {
  2222          "State" : {
  2223            "Running" : true,
  2224            "Paused" : false,
  2225            "Restarting" : false,
  2226            "OOMKilled" : false,
  2227            "Pid" : 3650,
  2228            "ExitCode" : 0,
  2229            "Error" : "",
  2230            "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  2231            "FinishedAt" : "0001-01-01T00:00:00Z"
  2232          },
  2233          "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  2234          "Created" : "2014-11-17T22:26:03.626304998Z",
  2235          "Path" : "date",
  2236          "Args" : [],
  2237          "Config" : {
  2238            "Hostname" : "8f177a186b97",
  2239            "Domainname" : "",
  2240            "User" : "",
  2241            "AttachStdin" : false,
  2242            "AttachStdout" : false,
  2243            "AttachStderr" : false,
  2244            "ExposedPorts" : null,
  2245            "Tty" : false,
  2246            "OpenStdin" : false,
  2247            "StdinOnce" : false,
  2248            "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2249            "Cmd" : [
  2250              "date"
  2251            ],
  2252            "Image" : "ubuntu",
  2253            "Volumes" : null,
  2254            "WorkingDir" : "",
  2255            "Entrypoint" : null,
  2256            "NetworkDisabled" : false,
  2257            "MacAddress" : "",
  2258            "OnBuild" : null,
  2259            "SecurityOpt" : null
  2260          },
  2261          "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2262          "NetworkSettings" : {
  2263            "IPAddress" : "172.17.0.2",
  2264            "IPPrefixLen" : 16,
  2265            "MacAddress" : "02:42:ac:11:00:02",
  2266            "Gateway" : "172.17.42.1",
  2267            "Bridge" : "docker0",
  2268            "PortMapping" : null,
  2269            "Ports" : {}
  2270          },
  2271          "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2272          "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2273          "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2274          "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2275          "Name" : "/test",
  2276          "Driver" : "aufs",
  2277          "ExecDriver" : "native-0.2",
  2278          "MountLabel" : "",
  2279          "ProcessLabel" : "",
  2280          "AppArmorProfile" : "",
  2281          "RestartCount" : 0,
  2282          "Mounts" : []
  2283        }
  2284      }
  2285  
  2286  Status Codes:
  2287  
  2288  -   **200** – no error
  2289  -   **404** – no such exec instance
  2290  -   **500** - server error
  2291  
  2292  # 3. Going further
  2293  
  2294  ## 3.1 Inside `docker run`
  2295  
  2296  As an example, the `docker run` command line makes the following API calls:
  2297  
  2298  - Create the container
  2299  
  2300  - If the status code is 404, it means the image doesn't exist:
  2301      - Try to pull it.
  2302      - Then, retry to create the container.
  2303  
  2304  - Start the container.
  2305  
  2306  - If you are not in detached mode:
  2307  - Attach to the container, using `logs=1` (to have `stdout` and
  2308        `stderr` from the container's start) and `stream=1`
  2309  
  2310  - If in detached mode or only `stdin` is attached, display the container's id.
  2311  
  2312  ## 3.2 Hijacking
  2313  
  2314  In this version of the API, `/attach`, uses hijacking to transport `stdin`,
  2315  `stdout`, and `stderr` on the same socket.
  2316  
  2317  To hint potential proxies about connection hijacking, Docker client sends
  2318  connection upgrade headers similarly to websocket.
  2319  
  2320      Upgrade: tcp
  2321      Connection: Upgrade
  2322  
  2323  When Docker daemon detects the `Upgrade` header, it switches its status code
  2324  from **200 OK** to **101 UPGRADED** and resends the same headers.
  2325  
  2326  
  2327  ## 3.3 CORS Requests
  2328  
  2329  To set cross origin requests to the remote api please give values to 
  2330  `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
  2331  default or blank means CORS disabled
  2332  
  2333      $ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"