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