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