Browse code

Bump api version to 1.18

Signed-off-by: Alexander Morozov <lk4d4@docker.com>

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