Browse code

api/docs: restore API versions v1.14 - v1.17

This reverts commit 68f9a45440c1d87316ec5106f942a8cae9113ca0.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

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