github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/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="engine_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](../../quickstart.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 enable unlimited 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`, `none`, 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 or name)/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 or name)/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 or name)/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 or name)/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 or name)/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 or name)/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                    8646879,
   699                    24472255,
   700                    36438778,
   701                    30657443
   702                 ],
   703                 "usage_in_usermode" : 50000000,
   704                 "total_usage" : 100215355,
   705                 "usage_in_kernelmode" : 30000000
   706              },
   707              "system_cpu_usage" : 739306590000000,
   708              "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0}
   709           },
   710           "precpu_stats" : {
   711              "cpu_usage" : {
   712                 "percpu_usage" : [
   713                    8646879,
   714                    24350896,
   715                    36438778,
   716                    30657443
   717                 ],
   718                 "usage_in_usermode" : 50000000,
   719                 "total_usage" : 100093996,
   720                 "usage_in_kernelmode" : 30000000
   721              },
   722              "system_cpu_usage" : 9492140000000,
   723              "throttling_data" : {"periods":0,"throttled_periods":0,"throttled_time":0}
   724           }
   725        }
   726  
   727  The precpu_stats is the cpu statistic of last read, which is used for calculating the cpu usage percent. It is not the exact copy of the “cpu_stats” field.
   728  
   729  Query Parameters:
   730  
   731  -   **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
   732  
   733  Status Codes:
   734  
   735  -   **200** – no error
   736  -   **404** – no such container
   737  -   **500** – server error
   738  
   739  ### Resize a container TTY
   740  
   741  `POST /containers/(id or name)/resize?h=<height>&w=<width>`
   742  
   743  Resize the TTY for container with  `id`. You must restart the container for the resize to take effect.
   744  
   745  **Example request**:
   746  
   747        POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   748  
   749  **Example response**:
   750  
   751        HTTP/1.1 200 OK
   752        Content-Length: 0
   753        Content-Type: text/plain; charset=utf-8
   754  
   755  Status Codes:
   756  
   757  -   **200** – no error
   758  -   **404** – No such container
   759  -   **500** – Cannot resize container
   760  
   761  ### Start a container
   762  
   763  `POST /containers/(id or name)/start`
   764  
   765  Start the container `id`
   766  
   767  > **Note**:
   768  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   769  > See [create a container](#create-a-container) for details.
   770  
   771  **Example request**:
   772  
   773      POST /containers/e90e34656806/start HTTP/1.1
   774  
   775  **Example response**:
   776  
   777      HTTP/1.1 204 No Content
   778  
   779  Status Codes:
   780  
   781  -   **204** – no error
   782  -   **304** – container already started
   783  -   **404** – no such container
   784  -   **500** – server error
   785  
   786  ### Stop a container
   787  
   788  `POST /containers/(id or name)/stop`
   789  
   790  Stop the container `id`
   791  
   792  **Example request**:
   793  
   794      POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   795  
   796  **Example response**:
   797  
   798      HTTP/1.1 204 No Content
   799  
   800  Query Parameters:
   801  
   802  -   **t** – number of seconds to wait before killing the container
   803  
   804  Status Codes:
   805  
   806  -   **204** – no error
   807  -   **304** – container already stopped
   808  -   **404** – no such container
   809  -   **500** – server error
   810  
   811  ### Restart a container
   812  
   813  `POST /containers/(id or name)/restart`
   814  
   815  Restart the container `id`
   816  
   817  **Example request**:
   818  
   819      POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   820  
   821  **Example response**:
   822  
   823      HTTP/1.1 204 No Content
   824  
   825  Query Parameters:
   826  
   827  -   **t** – number of seconds to wait before killing the container
   828  
   829  Status Codes:
   830  
   831  -   **204** – no error
   832  -   **404** – no such container
   833  -   **500** – server error
   834  
   835  ### Kill a container
   836  
   837  `POST /containers/(id or name)/kill`
   838  
   839  Kill the container `id`
   840  
   841  **Example request**:
   842  
   843      POST /containers/e90e34656806/kill HTTP/1.1
   844  
   845  **Example response**:
   846  
   847      HTTP/1.1 204 No Content
   848  
   849  Query Parameters
   850  
   851  -   **signal** - Signal to send to the container: integer or string like `SIGINT`.
   852          When not set, `SIGKILL` is assumed and the call waits for the container to exit.
   853  
   854  Status Codes:
   855  
   856  -   **204** – no error
   857  -   **404** – no such container
   858  -   **500** – server error
   859  
   860  ### Rename a container
   861  
   862  `POST /containers/(id or name)/rename`
   863  
   864  Rename the container `id` to a `new_name`
   865  
   866  **Example request**:
   867  
   868      POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
   869  
   870  **Example response**:
   871  
   872      HTTP/1.1 204 No Content
   873  
   874  Query Parameters:
   875  
   876  -   **name** – new name for the container
   877  
   878  Status Codes:
   879  
   880  -   **204** – no error
   881  -   **404** – no such container
   882  -   **409** - conflict name already assigned
   883  -   **500** – server error
   884  
   885  ### Pause a container
   886  
   887  `POST /containers/(id or name)/pause`
   888  
   889  Pause the container `id`
   890  
   891  **Example request**:
   892  
   893      POST /containers/e90e34656806/pause HTTP/1.1
   894  
   895  **Example response**:
   896  
   897      HTTP/1.1 204 No Content
   898  
   899  Status Codes:
   900  
   901  -   **204** – no error
   902  -   **404** – no such container
   903  -   **500** – server error
   904  
   905  ### Unpause a container
   906  
   907  `POST /containers/(id or name)/unpause`
   908  
   909  Unpause the container `id`
   910  
   911  **Example request**:
   912  
   913      POST /containers/e90e34656806/unpause HTTP/1.1
   914  
   915  **Example response**:
   916  
   917      HTTP/1.1 204 No Content
   918  
   919  Status Codes:
   920  
   921  -   **204** – no error
   922  -   **404** – no such container
   923  -   **500** – server error
   924  
   925  ### Attach to a container
   926  
   927  `POST /containers/(id or name)/attach`
   928  
   929  Attach to the container `id`
   930  
   931  **Example request**:
   932  
   933      POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   934  
   935  **Example response**:
   936  
   937      HTTP/1.1 101 UPGRADED
   938      Content-Type: application/vnd.docker.raw-stream
   939      Connection: Upgrade
   940      Upgrade: tcp
   941  
   942      {{ STREAM }}
   943  
   944  Query Parameters:
   945  
   946  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
   947  -   **stream** – 1/True/true or 0/False/false, return stream.
   948          Default `false`.
   949  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
   950          to `stdin`. Default `false`.
   951  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
   952          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
   953  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
   954          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
   955  
   956  Status Codes:
   957  
   958  -   **101** – no error, hints proxy about hijacking
   959  -   **200** – no error, no upgrade header found
   960  -   **400** – bad parameter
   961  -   **404** – no such container
   962  -   **500** – server error
   963  
   964      **Stream details**:
   965  
   966      When using the TTY setting is enabled in
   967      [`POST /containers/create`
   968      ](#create-a-container),
   969      the stream is the raw data from the process PTY and client's `stdin`.
   970      When the TTY is disabled, then the stream is multiplexed to separate
   971      `stdout` and `stderr`.
   972  
   973      The format is a **Header** and a **Payload** (frame).
   974  
   975      **HEADER**
   976  
   977      The header contains the information which the stream writes (`stdout` or
   978      `stderr`). It also contains the size of the associated frame encoded in the
   979      last four bytes (`uint32`).
   980  
   981      It is encoded on the first eight bytes like this:
   982  
   983          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   984  
   985      `STREAM_TYPE` can be:
   986  
   987  -   0: `stdin` (is written on `stdout`)
   988  -   1: `stdout`
   989  -   2: `stderr`
   990  
   991      `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
   992      the `uint32` size encoded as big endian.
   993  
   994      **PAYLOAD**
   995  
   996      The payload is the raw stream.
   997  
   998      **IMPLEMENTATION**
   999  
  1000      The simplest way to implement the Attach protocol is the following:
  1001  
  1002      1.  Read eight bytes.
  1003      2.  Choose `stdout` or `stderr` depending on the first byte.
  1004      3.  Extract the frame size from the last four bytes.
  1005      4.  Read the extracted size and output it on the correct output.
  1006      5.  Goto 1.
  1007  
  1008  ### Attach to a container (websocket)
  1009  
  1010  `GET /containers/(id or name)/attach/ws`
  1011  
  1012  Attach to the container `id` via websocket
  1013  
  1014  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
  1015  
  1016  **Example request**
  1017  
  1018      GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
  1019  
  1020  **Example response**
  1021  
  1022      {{ STREAM }}
  1023  
  1024  Query Parameters:
  1025  
  1026  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
  1027  -   **stream** – 1/True/true or 0/False/false, return stream.
  1028          Default `false`.
  1029  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
  1030          to `stdin`. Default `false`.
  1031  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
  1032          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
  1033  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
  1034          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
  1035  
  1036  Status Codes:
  1037  
  1038  -   **200** – no error
  1039  -   **400** – bad parameter
  1040  -   **404** – no such container
  1041  -   **500** – server error
  1042  
  1043  ### Wait a container
  1044  
  1045  `POST /containers/(id or name)/wait`
  1046  
  1047  Block until container `id` stops, then returns the exit code
  1048  
  1049  **Example request**:
  1050  
  1051      POST /containers/16253994b7c4/wait HTTP/1.1
  1052  
  1053  **Example response**:
  1054  
  1055      HTTP/1.1 200 OK
  1056      Content-Type: application/json
  1057  
  1058      {"StatusCode": 0}
  1059  
  1060  Status Codes:
  1061  
  1062  -   **200** – no error
  1063  -   **404** – no such container
  1064  -   **500** – server error
  1065  
  1066  ### Remove a container
  1067  
  1068  `DELETE /containers/(id or name)`
  1069  
  1070  Remove the container `id` from the filesystem
  1071  
  1072  **Example request**:
  1073  
  1074      DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  1075  
  1076  **Example response**:
  1077  
  1078      HTTP/1.1 204 No Content
  1079  
  1080  Query Parameters:
  1081  
  1082  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1083          associated to the container. Default `false`.
  1084  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1085          Default `false`.
  1086  
  1087  Status Codes:
  1088  
  1089  -   **204** – no error
  1090  -   **400** – bad parameter
  1091  -   **404** – no such container
  1092  -   **500** – server error
  1093  
  1094  ### Copy files or folders from a container
  1095  
  1096  `POST /containers/(id or name)/copy`
  1097  
  1098  Copy files or folders of container `id`
  1099  
  1100  **Deprecated** in favor of the `archive` endpoint below.
  1101  
  1102  **Example request**:
  1103  
  1104      POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1105      Content-Type: application/json
  1106  
  1107      {
  1108           "Resource": "test.txt"
  1109      }
  1110  
  1111  **Example response**:
  1112  
  1113      HTTP/1.1 200 OK
  1114      Content-Type: application/x-tar
  1115  
  1116      {{ TAR STREAM }}
  1117  
  1118  Status Codes:
  1119  
  1120  -   **200** – no error
  1121  -   **404** – no such container
  1122  -   **500** – server error
  1123  
  1124  ### Retrieving information about files and folders in a container
  1125  
  1126  `HEAD /containers/(id or name)/archive`
  1127  
  1128  See the description of the `X-Docker-Container-Path-Stat` header in the
  1129  following section.
  1130  
  1131  ### Get an archive of a filesystem resource in a container
  1132  
  1133  `GET /containers/(id or name)/archive`
  1134  
  1135  Get an tar archive of a resource in the filesystem of container `id`.
  1136  
  1137  Query Parameters:
  1138  
  1139  - **path** - resource in the container's filesystem to archive. Required.
  1140  
  1141      If not an absolute path, it is relative to the container's root directory.
  1142      The resource specified by **path** must exist. To assert that the resource
  1143      is expected to be a directory, **path** should end in `/` or  `/.`
  1144      (assuming a path separator of `/`). If **path** ends in `/.` then this
  1145      indicates that only the contents of the **path** directory should be
  1146      copied. A symlink is always resolved to its target.
  1147  
  1148      **Note**: It is not possible to copy certain system files such as resources
  1149      under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
  1150      container.
  1151  
  1152  **Example request**:
  1153  
  1154          GET /containers/8cce319429b2/archive?path=/root HTTP/1.1
  1155  
  1156  **Example response**:
  1157  
  1158          HTTP/1.1 200 OK
  1159          Content-Type: application/x-tar
  1160          X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
  1161  
  1162          {{ TAR STREAM }}
  1163  
  1164  On success, a response header `X-Docker-Container-Path-Stat` will be set to a
  1165  base64-encoded JSON object containing some filesystem header information about
  1166  the archived resource. The above example value would decode to the following
  1167  JSON object (whitespace added for readability):
  1168  
  1169          {
  1170              "name": "root",
  1171              "size": 4096,
  1172              "mode": 2147484096,
  1173              "mtime": "2014-02-27T20:51:23Z",
  1174              "linkTarget": ""
  1175          }
  1176  
  1177  A `HEAD` request can also be made to this endpoint if only this information is
  1178  desired.
  1179  
  1180  Status Codes:
  1181  
  1182  - **200** - success, returns archive of copied resource
  1183  - **400** - client error, bad parameter, details in JSON response body, one of:
  1184      - must specify path parameter (**path** cannot be empty)
  1185      - not a directory (**path** was asserted to be a directory but exists as a
  1186        file)
  1187  - **404** - client error, resource not found, one of:
  1188      – no such container (container `id` does not exist)
  1189      - no such file or directory (**path** does not exist)
  1190  - **500** - server error
  1191  
  1192  ### Extract an archive of files or folders to a directory in a container
  1193  
  1194  `PUT /containers/(id or name)/archive`
  1195  
  1196  Upload a tar archive to be extracted to a path in the filesystem of container
  1197  `id`.
  1198  
  1199  Query Parameters:
  1200  
  1201  - **path** - path to a directory in the container
  1202      to extract the archive's contents into. Required.
  1203  
  1204      If not an absolute path, it is relative to the container's root directory.
  1205      The **path** resource must exist.
  1206  - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error
  1207      if unpacking the given content would cause an existing directory to be
  1208      replaced with a non-directory and vice versa.
  1209  
  1210  **Example request**:
  1211  
  1212          PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
  1213          Content-Type: application/x-tar
  1214  
  1215          {{ TAR STREAM }}
  1216  
  1217  **Example response**:
  1218  
  1219          HTTP/1.1 200 OK
  1220  
  1221  Status Codes:
  1222  
  1223  - **200** – the content was extracted successfully
  1224  - **400** - client error, bad parameter, details in JSON response body, one of:
  1225      - must specify path parameter (**path** cannot be empty)
  1226      - not a directory (**path** should be a directory but exists as a file)
  1227      - unable to overwrite existing directory with non-directory
  1228        (if **noOverwriteDirNonDir**)
  1229      - unable to overwrite existing non-directory with directory
  1230        (if **noOverwriteDirNonDir**)
  1231  - **403** - client error, permission denied, the volume
  1232      or container rootfs is marked as read-only.
  1233  - **404** - client error, resource not found, one of:
  1234      – no such container (container `id` does not exist)
  1235      - no such file or directory (**path** resource does not exist)
  1236  - **500** – server error
  1237  
  1238  ## 2.2 Images
  1239  
  1240  ### List Images
  1241  
  1242  `GET /images/json`
  1243  
  1244  **Example request**:
  1245  
  1246      GET /images/json?all=0 HTTP/1.1
  1247  
  1248  **Example response**:
  1249  
  1250      HTTP/1.1 200 OK
  1251      Content-Type: application/json
  1252  
  1253      [
  1254        {
  1255           "RepoTags": [
  1256             "ubuntu:12.04",
  1257             "ubuntu:precise",
  1258             "ubuntu:latest"
  1259           ],
  1260           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1261           "Created": 1365714795,
  1262           "Size": 131506275,
  1263           "VirtualSize": 131506275,
  1264           "Labels": {}
  1265        },
  1266        {
  1267           "RepoTags": [
  1268             "ubuntu:12.10",
  1269             "ubuntu:quantal"
  1270           ],
  1271           "ParentId": "27cf784147099545",
  1272           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1273           "Created": 1364102658,
  1274           "Size": 24653,
  1275           "VirtualSize": 180116135,
  1276           "Labels": {
  1277              "com.example.version": "v1"
  1278           }
  1279        }
  1280      ]
  1281  
  1282  **Example request, with digest information**:
  1283  
  1284      GET /images/json?digests=1 HTTP/1.1
  1285  
  1286  **Example response, with digest information**:
  1287  
  1288      HTTP/1.1 200 OK
  1289      Content-Type: application/json
  1290  
  1291      [
  1292        {
  1293          "Created": 1420064636,
  1294          "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1295          "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1296          "RepoDigests": [
  1297            "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1298          ],
  1299          "RepoTags": [
  1300            "localhost:5000/test/busybox:latest",
  1301            "playdate:latest"
  1302          ],
  1303          "Size": 0,
  1304          "VirtualSize": 2429728,
  1305          "Labels": {}
  1306        }
  1307      ]
  1308  
  1309  The response shows a single image `Id` associated with two repositories
  1310  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1311  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1312  `playdate:latest` to reference the image.
  1313  
  1314  You can also use `RepoDigests` values to reference an image. In this response,
  1315  the array has only one reference and that is to the
  1316  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1317  digest. You can reference this digest using the value:
  1318  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1319  
  1320  See the `docker run` and `docker build` commands for examples of digest and tag
  1321  references on the command line.
  1322  
  1323  Query Parameters:
  1324  
  1325  -   **all** – 1/True/true or 0/False/false, default false
  1326  -   **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1327    -   `dangling=true`
  1328    -   `label=key` or `label="key=value"` of an image label
  1329  -   **filter** - only return images with the specified name
  1330  
  1331  ### Build image from a Dockerfile
  1332  
  1333  `POST /build`
  1334  
  1335  Build an image from a Dockerfile
  1336  
  1337  **Example request**:
  1338  
  1339      POST /build HTTP/1.1
  1340  
  1341      {{ TAR STREAM }}
  1342  
  1343  **Example response**:
  1344  
  1345      HTTP/1.1 200 OK
  1346      Content-Type: application/json
  1347  
  1348      {"stream": "Step 1..."}
  1349      {"stream": "..."}
  1350      {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1351  
  1352  The input stream must be a `tar` archive compressed with one of the
  1353  following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
  1354  
  1355  The archive must include a build instructions file, typically called
  1356  `Dockerfile` at the archive's root. The `dockerfile` parameter may be
  1357  used to specify a different build instructions file. To do this, its value must be
  1358  the path to the alternate build instructions file to use.
  1359  
  1360  The archive may include any number of other files,
  1361  which are accessible in the build context (See the [*ADD build
  1362  command*](../../reference/builder.md#dockerbuilder)).
  1363  
  1364  The build is canceled if the client drops the connection by quitting
  1365  or being killed.
  1366  
  1367  Query Parameters:
  1368  
  1369  -   **dockerfile** - Path within the build context to the Dockerfile. This is 
  1370          ignored if `remote` is specified and points to an individual filename.
  1371  -   **t** – A repository name (and optionally a tag) to apply to
  1372          the resulting image in case of success.
  1373  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 
  1374          URI specifies a filename, the file's contents are placed into a file 
  1375  		called `Dockerfile`.
  1376  -   **q** – Suppress verbose build output.
  1377  -   **nocache** – Do not use the cache when building the image.
  1378  -   **pull** - Attempt to pull the image even if an older image exists locally.
  1379  -   **rm** - Remove intermediate containers after a successful build (default behavior).
  1380  -   **forcerm** - Always remove intermediate containers (includes `rm`).
  1381  -   **memory** - Set memory limit for build.
  1382  -   **memswap** - Total memory (memory + swap), `-1` to enable unlimited swap.
  1383  -   **cpushares** - CPU shares (relative weight).
  1384  -   **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
  1385  -   **cpuperiod** - The length of a CPU period in microseconds.
  1386  -   **cpuquota** - Microseconds of CPU time that the container can get in a CPU period.
  1387  
  1388      Request Headers:
  1389  
  1390  -   **Content-type** – Set to `"application/tar"`.
  1391  -   **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
  1392          object with the following structure:
  1393  
  1394              {
  1395                  "docker.example.com": {
  1396                      "username": "janedoe",
  1397                      "password": "hunter2"
  1398                  },
  1399                  "https://index.docker.io/v1/": {
  1400                      "username": "mobydock",
  1401                      "password": "conta1n3rize14"
  1402                  }
  1403              }
  1404  
  1405          This object maps the hostname of a registry to an object containing the
  1406          "username" and "password" for that registry. Multiple registries may
  1407          be specified as the build may be based on an image requiring
  1408          authentication to pull from any arbitrary registry. Only the registry
  1409          domain name (and port if not the default "443") are required. However
  1410          (for legacy reasons) the "official" Docker, Inc. hosted registry must
  1411          be specified with both a "https://" prefix and a "/v1/" suffix even
  1412          though Docker will prefer to use the v2 registry API.
  1413  
  1414  Status Codes:
  1415  
  1416  -   **200** – no error
  1417  -   **500** – server error
  1418  
  1419  ### Create an image
  1420  
  1421  `POST /images/create`
  1422  
  1423  Create an image either by pulling it from the registry or by importing it
  1424  
  1425  **Example request**:
  1426  
  1427      POST /images/create?fromImage=ubuntu HTTP/1.1
  1428  
  1429  **Example response**:
  1430  
  1431      HTTP/1.1 200 OK
  1432      Content-Type: application/json
  1433  
  1434      {"status": "Pulling..."}
  1435      {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1436      {"error": "Invalid..."}
  1437      ...
  1438  
  1439  When using this endpoint to pull an image from the registry, the
  1440  `X-Registry-Auth` header can be used to include
  1441  a base64-encoded AuthConfig object.
  1442  
  1443  Query Parameters:
  1444  
  1445  -   **fromImage** – Name of the image to pull.
  1446  -   **fromSrc** – Source to import.  The value may be a URL from which the image
  1447          can be retrieved or `-` to read the image from the request body.
  1448  -   **repo** – Repository name.
  1449  -   **tag** – Tag.
  1450  -   **registry** – The registry to pull from.
  1451  
  1452      Request Headers:
  1453  
  1454  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1455  
  1456  Status Codes:
  1457  
  1458  -   **200** – no error
  1459  -   **500** – server error
  1460  
  1461  
  1462  
  1463  ### Inspect an image
  1464  
  1465  `GET /images/(name)/json`
  1466  
  1467  Return low-level information on the image `name`
  1468  
  1469  **Example request**:
  1470  
  1471      GET /images/ubuntu/json HTTP/1.1
  1472  
  1473  **Example response**:
  1474  
  1475      HTTP/1.1 200 OK
  1476      Content-Type: application/json
  1477  
  1478      {
  1479           "Created": "2013-03-23T22:24:18.818426-07:00",
  1480           "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1481           "ContainerConfig":
  1482                   {
  1483                           "Hostname": "",
  1484                           "User": "",
  1485                           "AttachStdin": false,
  1486                           "AttachStdout": false,
  1487                           "AttachStderr": false,
  1488                           "Tty": true,
  1489                           "OpenStdin": true,
  1490                           "StdinOnce": false,
  1491                           "Env": null,
  1492                           "Cmd": ["/bin/bash"],
  1493                           "Dns": null,
  1494                           "Image": "ubuntu",
  1495                           "Labels": {
  1496                               "com.example.vendor": "Acme",
  1497                               "com.example.license": "GPL",
  1498                               "com.example.version": "1.0"
  1499                           },
  1500                           "Volumes": null,
  1501                           "VolumesFrom": "",
  1502                           "WorkingDir": ""
  1503                   },
  1504           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1505           "Parent": "27cf784147099545",
  1506           "Size": 6824592
  1507      }
  1508  
  1509  Status Codes:
  1510  
  1511  -   **200** – no error
  1512  -   **404** – no such image
  1513  -   **500** – server error
  1514  
  1515  ### Get the history of an image
  1516  
  1517  `GET /images/(name)/history`
  1518  
  1519  Return the history of the image `name`
  1520  
  1521  **Example request**:
  1522  
  1523      GET /images/ubuntu/history HTTP/1.1
  1524  
  1525  **Example response**:
  1526  
  1527      HTTP/1.1 200 OK
  1528      Content-Type: application/json
  1529  
  1530      [
  1531          {
  1532              "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
  1533              "Created": 1398108230,
  1534              "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
  1535              "Tags": [
  1536                  "ubuntu:lucid",
  1537                  "ubuntu:10.04"
  1538              ],
  1539              "Size": 182964289,
  1540              "Comment": ""
  1541          },
  1542          {
  1543              "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
  1544              "Created": 1398108222,
  1545              "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/",
  1546              "Tags": null,
  1547              "Size": 0,
  1548              "Comment": ""
  1549          },
  1550          {
  1551              "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
  1552              "Created": 1371157430,
  1553              "CreatedBy": "",
  1554              "Tags": [
  1555                  "scratch12:latest",
  1556                  "scratch:latest"
  1557              ],
  1558              "Size": 0,
  1559              "Comment": "Imported from -"
  1560          }
  1561      ]
  1562  
  1563  Status Codes:
  1564  
  1565  -   **200** – no error
  1566  -   **404** – no such image
  1567  -   **500** – server error
  1568  
  1569  ### Push an image on the registry
  1570  
  1571  `POST /images/(name)/push`
  1572  
  1573  Push the image `name` on the registry
  1574  
  1575  **Example request**:
  1576  
  1577      POST /images/test/push HTTP/1.1
  1578  
  1579  **Example response**:
  1580  
  1581      HTTP/1.1 200 OK
  1582      Content-Type: application/json
  1583  
  1584      {"status": "Pushing..."}
  1585      {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1586      {"error": "Invalid..."}
  1587      ...
  1588  
  1589  If you wish to push an image on to a private registry, that image must already have a tag
  1590  into a repository which references that registry `hostname` and `port`.  This repository name should
  1591  then be used in the URL. This duplicates the command line's flow.
  1592  
  1593  **Example request**:
  1594  
  1595      POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1596  
  1597  
  1598  Query Parameters:
  1599  
  1600  -   **tag** – The tag to associate with the image on the registry. This is optional.
  1601  
  1602  Request Headers:
  1603  
  1604  -   **X-Registry-Auth** – Include a base64-encoded AuthConfig.
  1605          object.
  1606  
  1607  Status Codes:
  1608  
  1609  -   **200** – no error
  1610  -   **404** – no such image
  1611  -   **500** – server error
  1612  
  1613  ### Tag an image into a repository
  1614  
  1615  `POST /images/(name)/tag`
  1616  
  1617  Tag the image `name` into a repository
  1618  
  1619  **Example request**:
  1620  
  1621      POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1622  
  1623  **Example response**:
  1624  
  1625      HTTP/1.1 201 OK
  1626  
  1627  Query Parameters:
  1628  
  1629  -   **repo** – The repository to tag in
  1630  -   **force** – 1/True/true or 0/False/false, default false
  1631  -   **tag** - The new tag name
  1632  
  1633  Status Codes:
  1634  
  1635  -   **201** – no error
  1636  -   **400** – bad parameter
  1637  -   **404** – no such image
  1638  -   **409** – conflict
  1639  -   **500** – server error
  1640  
  1641  ### Remove an image
  1642  
  1643  `DELETE /images/(name)`
  1644  
  1645  Remove the image `name` from the filesystem
  1646  
  1647  **Example request**:
  1648  
  1649      DELETE /images/test HTTP/1.1
  1650  
  1651  **Example response**:
  1652  
  1653      HTTP/1.1 200 OK
  1654      Content-type: application/json
  1655  
  1656      [
  1657       {"Untagged": "3e2f21a89f"},
  1658       {"Deleted": "3e2f21a89f"},
  1659       {"Deleted": "53b4f83ac9"}
  1660      ]
  1661  
  1662  Query Parameters:
  1663  
  1664  -   **force** – 1/True/true or 0/False/false, default false
  1665  -   **noprune** – 1/True/true or 0/False/false, default false
  1666  
  1667  Status Codes:
  1668  
  1669  -   **200** – no error
  1670  -   **404** – no such image
  1671  -   **409** – conflict
  1672  -   **500** – server error
  1673  
  1674  ### Search images
  1675  
  1676  `GET /images/search`
  1677  
  1678  Search for an image on [Docker Hub](https://hub.docker.com).
  1679  
  1680  > **Note**:
  1681  > The response keys have changed from API v1.6 to reflect the JSON
  1682  > sent by the registry server to the docker daemon's request.
  1683  
  1684  **Example request**:
  1685  
  1686      GET /images/search?term=sshd HTTP/1.1
  1687  
  1688  **Example response**:
  1689  
  1690      HTTP/1.1 200 OK
  1691      Content-Type: application/json
  1692  
  1693      [
  1694              {
  1695                  "description": "",
  1696                  "is_official": false,
  1697                  "is_automated": false,
  1698                  "name": "wma55/u1210sshd",
  1699                  "star_count": 0
  1700              },
  1701              {
  1702                  "description": "",
  1703                  "is_official": false,
  1704                  "is_automated": false,
  1705                  "name": "jdswinbank/sshd",
  1706                  "star_count": 0
  1707              },
  1708              {
  1709                  "description": "",
  1710                  "is_official": false,
  1711                  "is_automated": false,
  1712                  "name": "vgauthier/sshd",
  1713                  "star_count": 0
  1714              }
  1715      ...
  1716      ]
  1717  
  1718  Query Parameters:
  1719  
  1720  -   **term** – term to search
  1721  
  1722  Status Codes:
  1723  
  1724  -   **200** – no error
  1725  -   **500** – server error
  1726  
  1727  ## 2.3 Misc
  1728  
  1729  ### Check auth configuration
  1730  
  1731  `POST /auth`
  1732  
  1733  Get the default username and email
  1734  
  1735  **Example request**:
  1736  
  1737      POST /auth HTTP/1.1
  1738      Content-Type: application/json
  1739  
  1740      {
  1741           "username":" hannibal",
  1742           "password: "xxxx",
  1743           "email": "hannibal@a-team.com",
  1744           "serveraddress": "https://index.docker.io/v1/"
  1745      }
  1746  
  1747  **Example response**:
  1748  
  1749      HTTP/1.1 200 OK
  1750  
  1751  Status Codes:
  1752  
  1753  -   **200** – no error
  1754  -   **204** – no error
  1755  -   **500** – server error
  1756  
  1757  ### Display system-wide information
  1758  
  1759  `GET /info`
  1760  
  1761  Display system-wide information
  1762  
  1763  **Example request**:
  1764  
  1765      GET /info HTTP/1.1
  1766  
  1767  **Example response**:
  1768  
  1769      HTTP/1.1 200 OK
  1770      Content-Type: application/json
  1771  
  1772      {
  1773          "Containers": 11,
  1774          "CpuCfsPeriod": true,
  1775          "CpuCfsQuota": true,
  1776          "Debug": false,
  1777          "DockerRootDir": "/var/lib/docker",
  1778          "Driver": "btrfs",
  1779          "DriverStatus": [[""]],
  1780          "ExecutionDriver": "native-0.1",
  1781          "ExperimentalBuild": false,
  1782          "HttpProxy": "http://test:test@localhost:8080",
  1783          "HttpsProxy": "https://test:test@localhost:8080",
  1784          "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1785          "IPv4Forwarding": true,
  1786          "Images": 16,
  1787          "IndexServerAddress": "https://index.docker.io/v1/",
  1788          "InitPath": "/usr/bin/docker",
  1789          "InitSha1": "",
  1790          "KernelVersion": "3.12.0-1-amd64",
  1791          "Labels": [
  1792              "storage=ssd"
  1793          ],
  1794          "MemTotal": 2099236864,
  1795          "MemoryLimit": true,
  1796          "NCPU": 1,
  1797          "NEventsListener": 0,
  1798          "NFd": 11,
  1799          "NGoroutines": 21,
  1800          "Name": "prod-server-42",
  1801          "NoProxy": "9.81.1.160",
  1802          "OomKillDisable": true,
  1803          "OperatingSystem": "Boot2Docker",
  1804          "RegistryConfig": {
  1805              "IndexConfigs": {
  1806                  "docker.io": {
  1807                      "Mirrors": null,
  1808                      "Name": "docker.io",
  1809                      "Official": true,
  1810                      "Secure": true
  1811                  }
  1812              },
  1813              "InsecureRegistryCIDRs": [
  1814                  "127.0.0.0/8"
  1815              ]
  1816          },
  1817          "SwapLimit": false,
  1818          "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1819      }
  1820  
  1821  Status Codes:
  1822  
  1823  -   **200** – no error
  1824  -   **500** – server error
  1825  
  1826  ### Show the docker version information
  1827  
  1828  `GET /version`
  1829  
  1830  Show the docker version information
  1831  
  1832  **Example request**:
  1833  
  1834      GET /version HTTP/1.1
  1835  
  1836  **Example response**:
  1837  
  1838      HTTP/1.1 200 OK
  1839      Content-Type: application/json
  1840  
  1841      {
  1842           "Version": "1.5.0",
  1843           "Os": "linux",
  1844           "KernelVersion": "3.18.5-tinycore64",
  1845           "GoVersion": "go1.4.1",
  1846           "GitCommit": "a8a31ef",
  1847           "Arch": "amd64",
  1848           "ApiVersion": "1.20",
  1849           "Experimental": false
  1850      }
  1851  
  1852  Status Codes:
  1853  
  1854  -   **200** – no error
  1855  -   **500** – server error
  1856  
  1857  ### Ping the docker server
  1858  
  1859  `GET /_ping`
  1860  
  1861  Ping the docker server
  1862  
  1863  **Example request**:
  1864  
  1865      GET /_ping HTTP/1.1
  1866  
  1867  **Example response**:
  1868  
  1869      HTTP/1.1 200 OK
  1870      Content-Type: text/plain
  1871  
  1872      OK
  1873  
  1874  Status Codes:
  1875  
  1876  -   **200** - no error
  1877  -   **500** - server error
  1878  
  1879  ### Create a new image from a container's changes
  1880  
  1881  `POST /commit`
  1882  
  1883  Create a new image from a container's changes
  1884  
  1885  **Example request**:
  1886  
  1887      POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1888      Content-Type: application/json
  1889  
  1890      {
  1891           "Hostname": "",
  1892           "Domainname": "",
  1893           "User": "",
  1894           "AttachStdin": false,
  1895           "AttachStdout": true,
  1896           "AttachStderr": true,
  1897           "Tty": false,
  1898           "OpenStdin": false,
  1899           "StdinOnce": false,
  1900           "Env": null,
  1901           "Cmd": [
  1902                   "date"
  1903           ],
  1904           "Mounts": [
  1905             {
  1906               "Source": "/data",
  1907               "Destination": "/data",
  1908               "Mode": "ro,Z",
  1909               "RW": false
  1910             }
  1911           ],
  1912           "Labels": {
  1913                   "key1": "value1",
  1914                   "key2": "value2"
  1915            },
  1916           "WorkingDir": "",
  1917           "NetworkDisabled": false,
  1918           "ExposedPorts": {
  1919                   "22/tcp": {}
  1920           }
  1921      }
  1922  
  1923  **Example response**:
  1924  
  1925      HTTP/1.1 201 Created
  1926      Content-Type: application/json
  1927  
  1928      {"Id": "596069db4bf5"}
  1929  
  1930  Json Parameters:
  1931  
  1932  -  **config** - the container's configuration
  1933  
  1934  Query Parameters:
  1935  
  1936  -   **container** – source container
  1937  -   **repo** – repository
  1938  -   **tag** – tag
  1939  -   **comment** – commit message
  1940  -   **author** – author (e.g., "John Hannibal Smith
  1941      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1942  -   **pause** – 1/True/true or 0/False/false, whether to pause the container before committing
  1943  -   **changes** – Dockerfile instructions to apply while committing
  1944  
  1945  Status Codes:
  1946  
  1947  -   **201** – no error
  1948  -   **404** – no such container
  1949  -   **500** – server error
  1950  
  1951  ### Monitor Docker's events
  1952  
  1953  `GET /events`
  1954  
  1955  Get container events from docker, either in real time via streaming, or via
  1956  polling (using since).
  1957  
  1958  Docker containers report the following events:
  1959  
  1960      attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause
  1961  
  1962  and Docker images report:
  1963  
  1964      delete, import, pull, push, tag, untag
  1965  
  1966  **Example request**:
  1967  
  1968      GET /events?since=1374067924
  1969  
  1970  **Example response**:
  1971  
  1972      HTTP/1.1 200 OK
  1973      Content-Type: application/json
  1974  
  1975      {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1976      {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1977      {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1978      {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1979  
  1980  Query Parameters:
  1981  
  1982  -   **since** – Timestamp used for polling
  1983  -   **until** – Timestamp used for polling
  1984  -   **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1985    -   `event=<string>`; -- event to filter
  1986    -   `image=<string>`; -- image to filter
  1987    -   `container=<string>`; -- container to filter
  1988  
  1989  Status Codes:
  1990  
  1991  -   **200** – no error
  1992  -   **500** – server error
  1993  
  1994  ### Get a tarball containing all images in a repository
  1995  
  1996  `GET /images/(name)/get`
  1997  
  1998  Get a tarball containing all images and metadata for the repository specified
  1999  by `name`.
  2000  
  2001  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  2002  (and its parents) are returned. If `name` is an image ID, similarly only that
  2003  image (and its parents) are returned, but with the exclusion of the
  2004  'repositories' file in the tarball, as there were no image names referenced.
  2005  
  2006  See the [image tarball format](#image-tarball-format) for more details.
  2007  
  2008  **Example request**
  2009  
  2010      GET /images/ubuntu/get
  2011  
  2012  **Example response**:
  2013  
  2014      HTTP/1.1 200 OK
  2015      Content-Type: application/x-tar
  2016  
  2017      Binary data stream
  2018  
  2019  Status Codes:
  2020  
  2021  -   **200** – no error
  2022  -   **500** – server error
  2023  
  2024  ### Get a tarball containing all images.
  2025  
  2026  `GET /images/get`
  2027  
  2028  Get a tarball containing all images and metadata for one or more repositories.
  2029  
  2030  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  2031  `ubuntu:latest`), then only that image (and its parents) are returned; if it is
  2032  an image ID, similarly only that image (and its parents) are returned and there
  2033  would be no names referenced in the 'repositories' file for this image ID.
  2034  
  2035  See the [image tarball format](#image-tarball-format) for more details.
  2036  
  2037  **Example request**
  2038  
  2039      GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  2040  
  2041  **Example response**:
  2042  
  2043      HTTP/1.1 200 OK
  2044      Content-Type: application/x-tar
  2045  
  2046      Binary data stream
  2047  
  2048  Status Codes:
  2049  
  2050  -   **200** – no error
  2051  -   **500** – server error
  2052  
  2053  ### Load a tarball with a set of images and tags into docker
  2054  
  2055  `POST /images/load`
  2056  
  2057  Load a set of images and tags into a Docker repository.
  2058  See the [image tarball format](#image-tarball-format) for more details.
  2059  
  2060  **Example request**
  2061  
  2062      POST /images/load
  2063  
  2064      Tarball in body
  2065  
  2066  **Example response**:
  2067  
  2068      HTTP/1.1 200 OK
  2069  
  2070  Status Codes:
  2071  
  2072  -   **200** – no error
  2073  -   **500** – server error
  2074  
  2075  ### Image tarball format
  2076  
  2077  An image tarball contains one directory per image layer (named using its long ID),
  2078  each containing these files:
  2079  
  2080  - `VERSION`: currently `1.0` - the file format version
  2081  - `json`: detailed layer information, similar to `docker inspect layer_id`
  2082  - `layer.tar`: A tarfile containing the filesystem changes in this layer
  2083  
  2084  The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
  2085  for storing attribute changes and deletions.
  2086  
  2087  If the tarball defines a repository, the tarball should also include a `repositories` file at
  2088  the root that contains a list of repository and tag names mapped to layer IDs.
  2089  
  2090  ```
  2091  {"hello-world":
  2092      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  2093  }
  2094  ```
  2095  
  2096  ### Exec Create
  2097  
  2098  `POST /containers/(id or name)/exec`
  2099  
  2100  Sets up an exec instance in a running container `id`
  2101  
  2102  **Example request**:
  2103  
  2104      POST /containers/e90e34656806/exec HTTP/1.1
  2105      Content-Type: application/json
  2106  
  2107        {
  2108         "AttachStdin": false,
  2109         "AttachStdout": true,
  2110         "AttachStderr": true,
  2111         "Tty": false,
  2112         "Cmd": [
  2113                       "date"
  2114               ]
  2115        }
  2116  
  2117  **Example response**:
  2118  
  2119      HTTP/1.1 201 OK
  2120      Content-Type: application/json
  2121  
  2122      {
  2123           "Id": "f90e34656806",
  2124           "Warnings":[]
  2125      }
  2126  
  2127  Json Parameters:
  2128  
  2129  -   **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
  2130  -   **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
  2131  -   **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
  2132  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2133  -   **Cmd** - Command to run specified as a string or an array of strings.
  2134  
  2135  
  2136  Status Codes:
  2137  
  2138  -   **201** – no error
  2139  -   **404** – no such container
  2140  
  2141  ### Exec Start
  2142  
  2143  `POST /exec/(id)/start`
  2144  
  2145  Starts a previously set up `exec` instance `id`. If `detach` is true, this API
  2146  returns after starting the `exec` command. Otherwise, this API sets up an
  2147  interactive session with the `exec` command.
  2148  
  2149  **Example request**:
  2150  
  2151      POST /exec/e90e34656806/start HTTP/1.1
  2152      Content-Type: application/json
  2153  
  2154      {
  2155       "Detach": false,
  2156       "Tty": false
  2157      }
  2158  
  2159  **Example response**:
  2160  
  2161      HTTP/1.1 201 OK
  2162      Content-Type: application/json
  2163  
  2164      {{ STREAM }}
  2165  
  2166  Json Parameters:
  2167  
  2168  -   **Detach** - Detach from the `exec` command.
  2169  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2170  
  2171  Status Codes:
  2172  
  2173  -   **200** – no error
  2174  -   **404** – no such exec instance
  2175  
  2176      **Stream details**:
  2177      Similar to the stream behavior of `POST /containers/(id or name)/attach` API
  2178  
  2179  ### Exec Resize
  2180  
  2181  `POST /exec/(id)/resize`
  2182  
  2183  Resizes the `tty` session used by the `exec` command `id`.  The unit is number of characters.
  2184  This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
  2185  
  2186  **Example request**:
  2187  
  2188      POST /exec/e90e34656806/resize?h=40&w=80 HTTP/1.1
  2189      Content-Type: text/plain
  2190  
  2191  **Example response**:
  2192  
  2193      HTTP/1.1 201 OK
  2194      Content-Type: text/plain
  2195  
  2196  Query Parameters:
  2197  
  2198  -   **h** – height of `tty` session
  2199  -   **w** – width
  2200  
  2201  Status Codes:
  2202  
  2203  -   **201** – no error
  2204  -   **404** – no such exec instance
  2205  
  2206  ### Exec Inspect
  2207  
  2208  `GET /exec/(id)/json`
  2209  
  2210  Return low-level information about the `exec` command `id`.
  2211  
  2212  **Example request**:
  2213  
  2214      GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  2215  
  2216  **Example response**:
  2217  
  2218      HTTP/1.1 200 OK
  2219      Content-Type: plain/text
  2220  
  2221      {
  2222        "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  2223        "Running" : false,
  2224        "ExitCode" : 2,
  2225        "ProcessConfig" : {
  2226          "privileged" : false,
  2227          "user" : "",
  2228          "tty" : false,
  2229          "entrypoint" : "sh",
  2230          "arguments" : [
  2231            "-c",
  2232            "exit 2"
  2233          ]
  2234        },
  2235        "OpenStdin" : false,
  2236        "OpenStderr" : false,
  2237        "OpenStdout" : false,
  2238        "Container" : {
  2239          "State" : {
  2240            "Running" : true,
  2241            "Paused" : false,
  2242            "Restarting" : false,
  2243            "OOMKilled" : false,
  2244            "Pid" : 3650,
  2245            "ExitCode" : 0,
  2246            "Error" : "",
  2247            "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  2248            "FinishedAt" : "0001-01-01T00:00:00Z"
  2249          },
  2250          "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  2251          "Created" : "2014-11-17T22:26:03.626304998Z",
  2252          "Path" : "date",
  2253          "Args" : [],
  2254          "Config" : {
  2255            "Hostname" : "8f177a186b97",
  2256            "Domainname" : "",
  2257            "User" : "",
  2258            "AttachStdin" : false,
  2259            "AttachStdout" : false,
  2260            "AttachStderr" : false,
  2261            "ExposedPorts" : null,
  2262            "Tty" : false,
  2263            "OpenStdin" : false,
  2264            "StdinOnce" : false,
  2265            "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2266            "Cmd" : [
  2267              "date"
  2268            ],
  2269            "Image" : "ubuntu",
  2270            "Volumes" : null,
  2271            "WorkingDir" : "",
  2272            "Entrypoint" : null,
  2273            "NetworkDisabled" : false,
  2274            "MacAddress" : "",
  2275            "OnBuild" : null,
  2276            "SecurityOpt" : null
  2277          },
  2278          "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2279          "NetworkSettings" : {
  2280            "IPAddress" : "172.17.0.2",
  2281            "IPPrefixLen" : 16,
  2282            "MacAddress" : "02:42:ac:11:00:02",
  2283            "Gateway" : "172.17.42.1",
  2284            "Bridge" : "docker0",
  2285            "PortMapping" : null,
  2286            "Ports" : {}
  2287          },
  2288          "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2289          "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2290          "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2291          "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2292          "Name" : "/test",
  2293          "Driver" : "aufs",
  2294          "ExecDriver" : "native-0.2",
  2295          "MountLabel" : "",
  2296          "ProcessLabel" : "",
  2297          "AppArmorProfile" : "",
  2298          "RestartCount" : 0,
  2299          "Mounts" : []
  2300        }
  2301      }
  2302  
  2303  Status Codes:
  2304  
  2305  -   **200** – no error
  2306  -   **404** – no such exec instance
  2307  -   **500** - server error
  2308  
  2309  # 3. Going further
  2310  
  2311  ## 3.1 Inside `docker run`
  2312  
  2313  As an example, the `docker run` command line makes the following API calls:
  2314  
  2315  - Create the container
  2316  
  2317  - If the status code is 404, it means the image doesn't exist:
  2318      - Try to pull it.
  2319      - Then, retry to create the container.
  2320  
  2321  - Start the container.
  2322  
  2323  - If you are not in detached mode:
  2324  - Attach to the container, using `logs=1` (to have `stdout` and
  2325        `stderr` from the container's start) and `stream=1`
  2326  
  2327  - If in detached mode or only `stdin` is attached, display the container's id.
  2328  
  2329  ## 3.2 Hijacking
  2330  
  2331  In this version of the API, `/attach`, uses hijacking to transport `stdin`,
  2332  `stdout`, and `stderr` on the same socket.
  2333  
  2334  To hint potential proxies about connection hijacking, Docker client sends
  2335  connection upgrade headers similarly to websocket.
  2336  
  2337      Upgrade: tcp
  2338      Connection: Upgrade
  2339  
  2340  When Docker daemon detects the `Upgrade` header, it switches its status code
  2341  from **200 OK** to **101 UPGRADED** and resends the same headers.
  2342  
  2343  
  2344  ## 3.3 CORS Requests
  2345  
  2346  To set cross origin requests to the remote api please give values to 
  2347  `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
  2348  default or blank means CORS disabled
  2349  
  2350      $ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"