github.com/yogeshlonkar/moby@v1.13.2-0.20201203103638-c0b64beaea94/docs/api/v1.20.md (about)

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