Browse code

Add documentation

Guillaume J. Charmes authored on 2013/09/12 07:14:33
Showing 4 changed files
... ...
@@ -21,10 +21,12 @@ import (
21 21
 	"strings"
22 22
 )
23 23
 
24
-const APIVERSION = 1.5
25
-const DEFAULTHTTPHOST = "127.0.0.1"
26
-const DEFAULTHTTPPORT = 4243
27
-const DEFAULTUNIXSOCKET = "/var/run/docker.sock"
24
+const (
25
+	APIVERSION        = 1.6
26
+	DEFAULTHTTPHOST   = "127.0.0.1"
27
+	DEFAULTHTTPPORT   = 4243
28
+	DEFAULTUNIXSOCKET = "/var/run/docker.sock"
29
+)
28 30
 
29 31
 type HttpApiFunc func(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error
30 32
 
... ...
@@ -794,7 +796,7 @@ func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r
794 794
 
795 795
 	fmt.Fprintf(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
796 796
 
797
-	if !c.Config.Tty && version >= 1.4 {
797
+	if !c.Config.Tty && version >= 1.6 {
798 798
 		errStream = utils.NewStdWriter(outStream, utils.Stderr)
799 799
 		outStream = utils.NewStdWriter(outStream, utils.Stdout)
800 800
 	} else {
801 801
new file mode 100644
... ...
@@ -0,0 +1,52 @@
0
+:title: Attach stream API
1
+:description: API Documentation for the Attach command in Docker
2
+:keywords: API, Docker, Attach, Stream, REST, documentation
3
+
4
+=================
5
+Docker Attach stream API
6
+=================
7
+
8
+.. contents:: Table of Contents
9
+
10
+1. Brief introduction
11
+=====================
12
+
13
+- This is the Attach stream API for Docker
14
+
15
+2. Format
16
+=========
17
+
18
+The attach format is a Header and a Payload (frame).
19
+
20
+2.1 Header
21
+^^^^^^^^^^
22
+
23
+The header will contain the information on which stream write
24
+the stream (stdout or stderr).
25
+It also contain the size of the associated frame encoded on the last 4 bytes (uint32).
26
+
27
+It is encoded on the first 8 bytes like this:
28
+header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
29
+
30
+STREAM_TYPE can be:
31
+- 0: stdin (will be writen on stdout)
32
+- 1: stdout
33
+- 2: stderr
34
+
35
+SIZE1, SIZE2, SIZE3, SIZE4 are the 4 bytes of the uint32 size.
36
+
37
+2.1 Payload (frame)
38
+^^^^^^^^^^^^^^^^^^^
39
+
40
+The payload is the raw stream.
41
+
42
+3. Implementation
43
+=================
44
+
45
+The simplest way to implement the Attach protocol is the following:
46
+
47
+1) Read 8 bytes
48
+2) chose stdout or stderr depending on the first byte
49
+3) Extract the frame size from the last 4 byets
50
+4) Read the extracted size and output it on the correct output
51
+5) Goto 1)
... ...
@@ -27,14 +27,29 @@ Docker Remote API
27 27
 2. Versions
28 28
 ===========
29 29
 
30
-The current version of the API is 1.5
30
+The current version of the API is 1.6
31 31
 
32 32
 Calling /images/<name>/insert is the same as calling
33
-/v1.5/images/<name>/insert 
33
+/v1.6/images/<name>/insert
34 34
 
35 35
 You can still call an old version of the api using
36 36
 /v1.0/images/<name>/insert
37 37
 
38
+:doc:`docker_remote_api_v1.6`
39
+*****************************
40
+
41
+What's new
42
+----------
43
+
44
+.. http:post:: /containers/(id)/attach
45
+
46
+   **New!** You can now split stderr from stdout. This is done by prefixing
47
+   a header to each transmition. See :doc:`attach_api_1.6`.
48
+   The WebSocket attach is unchanged.
49
+   Note that attach calls on previous API version didn't change. Stdout and
50
+   stderr are merge.
51
+
52
+
38 53
 :doc:`docker_remote_api_v1.5`
39 54
 *****************************
40 55
 
41 56
new file mode 100644
... ...
@@ -0,0 +1,1175 @@
0
+:title: Remote API v1.6
1
+:description: API Documentation for Docker
2
+:keywords: API, Docker, rcli, REST, documentation
3
+
4
+:orphan:
5
+
6
+======================
7
+Docker Remote API v1.6
8
+======================
9
+
10
+.. contents:: Table of Contents
11
+
12
+1. Brief introduction
13
+=====================
14
+
15
+- The Remote API is replacing rcli
16
+- Default port in the docker daemon is 4243
17
+- The API tends to be REST, but for some complex commands, like attach or pull, the HTTP connection is hijacked to transport stdout stdin and stderr
18
+
19
+2. Endpoints
20
+============
21
+
22
+2.1 Containers
23
+--------------
24
+
25
+List containers
26
+***************
27
+
28
+.. http:get:: /containers/json
29
+
30
+	List containers
31
+
32
+	**Example request**:
33
+
34
+	.. sourcecode:: http
35
+
36
+	   GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
37
+	   
38
+	**Example response**:
39
+
40
+	.. sourcecode:: http
41
+
42
+	   HTTP/1.1 200 OK
43
+	   Content-Type: application/json
44
+	   
45
+	   [
46
+		{
47
+			"Id": "8dfafdbc3a40",
48
+			"Image": "base:latest",
49
+			"Command": "echo 1",
50
+			"Created": 1367854155,
51
+			"Status": "Exit 0",
52
+			"Ports":[{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
53
+			"SizeRw":12288,
54
+			"SizeRootFs":0
55
+		},
56
+		{
57
+			"Id": "9cd87474be90",
58
+			"Image": "base:latest",
59
+			"Command": "echo 222222",
60
+			"Created": 1367854155,
61
+			"Status": "Exit 0",
62
+			"Ports":[],
63
+			"SizeRw":12288,
64
+			"SizeRootFs":0
65
+		},
66
+		{
67
+			"Id": "3176a2479c92",
68
+			"Image": "base:latest",
69
+			"Command": "echo 3333333333333333",
70
+			"Created": 1367854154,
71
+			"Status": "Exit 0",
72
+			"Ports":[],
73
+			"SizeRw":12288,
74
+			"SizeRootFs":0
75
+		},
76
+		{
77
+			"Id": "4cb07b47f9fb",
78
+			"Image": "base:latest",
79
+			"Command": "echo 444444444444444444444444444444444",
80
+			"Created": 1367854152,
81
+			"Status": "Exit 0",
82
+			"Ports":[],
83
+			"SizeRw":12288,
84
+			"SizeRootFs":0
85
+		}
86
+	   ]
87
+ 
88
+	:query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
89
+	:query limit: Show ``limit`` last created containers, include non-running ones.
90
+	:query since: Show only containers created since Id, include non-running ones.
91
+	:query before: Show only containers created before Id, include non-running ones.
92
+	:query size: 1/True/true or 0/False/false, Show the containers sizes
93
+	:statuscode 200: no error
94
+	:statuscode 400: bad parameter
95
+	:statuscode 500: server error
96
+
97
+
98
+Create a container
99
+******************
100
+
101
+.. http:post:: /containers/create
102
+
103
+	Create a container
104
+
105
+	**Example request**:
106
+
107
+	.. sourcecode:: http
108
+
109
+	   POST /containers/create HTTP/1.1
110
+	   Content-Type: application/json
111
+
112
+	   {
113
+		"Hostname":"",
114
+		"User":"",
115
+		"Memory":0,
116
+		"MemorySwap":0,
117
+		"AttachStdin":false,
118
+		"AttachStdout":true,
119
+		"AttachStderr":true,
120
+		"PortSpecs":null,
121
+		"Privileged": false,
122
+		"Tty":false,
123
+		"OpenStdin":false,
124
+		"StdinOnce":false,
125
+		"Env":null,
126
+		"Cmd":[
127
+			"date"
128
+		],
129
+		"Dns":null,
130
+		"Image":"base",
131
+		"Volumes":{},
132
+		"VolumesFrom":"",
133
+		"WorkingDir":""
134
+
135
+	   }
136
+	   
137
+	**Example response**:
138
+
139
+	.. sourcecode:: http
140
+
141
+	   HTTP/1.1 201 OK
142
+	   Content-Type: application/json
143
+
144
+	   {
145
+		"Id":"e90e34656806"
146
+		"Warnings":[]
147
+	   }
148
+	
149
+	:jsonparam config: the container's configuration
150
+	:statuscode 201: no error
151
+	:statuscode 404: no such container
152
+	:statuscode 406: impossible to attach (container not running)
153
+	:statuscode 500: server error
154
+
155
+
156
+Inspect a container
157
+*******************
158
+
159
+.. http:get:: /containers/(id)/json
160
+
161
+	Return low-level information on the container ``id``
162
+
163
+	**Example request**:
164
+
165
+	.. sourcecode:: http
166
+
167
+	   GET /containers/4fa6e0f0c678/json HTTP/1.1
168
+	   
169
+	**Example response**:
170
+
171
+	.. sourcecode:: http
172
+
173
+	   HTTP/1.1 200 OK
174
+	   Content-Type: application/json
175
+
176
+	   {
177
+			"Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
178
+			"Created": "2013-05-07T14:51:42.041847+02:00",
179
+			"Path": "date",
180
+			"Args": [],
181
+			"Config": {
182
+				"Hostname": "4fa6e0f0c678",
183
+				"User": "",
184
+				"Memory": 0,
185
+				"MemorySwap": 0,
186
+				"AttachStdin": false,
187
+				"AttachStdout": true,
188
+				"AttachStderr": true,
189
+				"PortSpecs": null,
190
+				"Tty": false,
191
+				"OpenStdin": false,
192
+				"StdinOnce": false,
193
+				"Env": null,
194
+				"Cmd": [
195
+					"date"
196
+				],
197
+				"Dns": null,
198
+				"Image": "base",
199
+				"Volumes": {},
200
+				"VolumesFrom": "",
201
+				"WorkingDir":""
202
+
203
+			},
204
+			"State": {
205
+				"Running": false,
206
+				"Pid": 0,
207
+				"ExitCode": 0,
208
+				"StartedAt": "2013-05-07T14:51:42.087658+02:01360",
209
+				"Ghost": false
210
+			},
211
+			"Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
212
+			"NetworkSettings": {
213
+				"IpAddress": "",
214
+				"IpPrefixLen": 0,
215
+				"Gateway": "",
216
+				"Bridge": "",
217
+				"PortMapping": null
218
+			},
219
+			"SysInitPath": "/home/kitty/go/src/github.com/dotcloud/docker/bin/docker",
220
+			"ResolvConfPath": "/etc/resolv.conf",
221
+			"Volumes": {}
222
+	   }
223
+
224
+	:statuscode 200: no error
225
+	:statuscode 404: no such container
226
+	:statuscode 500: server error
227
+
228
+
229
+List processes running inside a container
230
+*****************************************
231
+
232
+.. http:get:: /containers/(id)/top
233
+
234
+	List processes running inside the container ``id``
235
+
236
+	**Example request**:
237
+
238
+	.. sourcecode:: http
239
+
240
+	   GET /containers/4fa6e0f0c678/top HTTP/1.1
241
+
242
+	**Example response**:
243
+
244
+	.. sourcecode:: http
245
+
246
+	   HTTP/1.1 200 OK
247
+	   Content-Type: application/json
248
+
249
+	   {
250
+		"Titles":[
251
+			"USER",
252
+			"PID",
253
+			"%CPU",
254
+			"%MEM",
255
+			"VSZ",
256
+			"RSS",
257
+			"TTY",
258
+			"STAT",
259
+			"START",
260
+			"TIME",
261
+			"COMMAND"
262
+			],
263
+		"Processes":[
264
+			["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
265
+			["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
266
+		]
267
+	   }
268
+
269
+	:query ps_args: ps arguments to use (eg. aux)
270
+	:statuscode 200: no error
271
+	:statuscode 404: no such container
272
+	:statuscode 500: server error
273
+
274
+
275
+Inspect changes on a container's filesystem
276
+*******************************************
277
+
278
+.. http:get:: /containers/(id)/changes
279
+
280
+	Inspect changes on container ``id`` 's filesystem
281
+
282
+	**Example request**:
283
+
284
+	.. sourcecode:: http
285
+
286
+	   GET /containers/4fa6e0f0c678/changes HTTP/1.1
287
+
288
+	   
289
+	**Example response**:
290
+
291
+	.. sourcecode:: http
292
+
293
+	   HTTP/1.1 200 OK
294
+	   Content-Type: application/json
295
+	   
296
+	   [
297
+		{
298
+			"Path":"/dev",
299
+			"Kind":0
300
+		},
301
+		{
302
+			"Path":"/dev/kmsg",
303
+			"Kind":1
304
+		},
305
+		{
306
+			"Path":"/test",
307
+			"Kind":1
308
+		}
309
+	   ]
310
+
311
+	:statuscode 200: no error
312
+	:statuscode 404: no such container
313
+	:statuscode 500: server error
314
+
315
+
316
+Export a container
317
+******************
318
+
319
+.. http:get:: /containers/(id)/export
320
+
321
+	Export the contents of container ``id``
322
+
323
+	**Example request**:
324
+
325
+	.. sourcecode:: http
326
+
327
+	   GET /containers/4fa6e0f0c678/export HTTP/1.1
328
+
329
+	   
330
+	**Example response**:
331
+
332
+	.. sourcecode:: http
333
+
334
+	   HTTP/1.1 200 OK
335
+	   Content-Type: application/octet-stream
336
+	   
337
+	   {{ STREAM }}
338
+
339
+	:statuscode 200: no error
340
+	:statuscode 404: no such container
341
+	:statuscode 500: server error
342
+
343
+
344
+Start a container
345
+*****************
346
+
347
+.. http:post:: /containers/(id)/start
348
+
349
+        Start the container ``id``
350
+
351
+        **Example request**:
352
+
353
+        .. sourcecode:: http
354
+
355
+           POST /containers/(id)/start HTTP/1.1
356
+           Content-Type: application/json
357
+
358
+           {
359
+                "Binds":["/tmp:/tmp"],
360
+                "LxcConf":{"lxc.utsname":"docker"}
361
+           }
362
+
363
+        **Example response**:
364
+
365
+        .. sourcecode:: http
366
+
367
+           HTTP/1.1 204 No Content
368
+           Content-Type: text/plain
369
+
370
+        :jsonparam hostConfig: the container's host configuration (optional)
371
+        :statuscode 204: no error
372
+        :statuscode 404: no such container
373
+        :statuscode 500: server error
374
+
375
+
376
+Stop a container
377
+****************
378
+
379
+.. http:post:: /containers/(id)/stop
380
+
381
+	Stop the container ``id``
382
+
383
+	**Example request**:
384
+
385
+	.. sourcecode:: http
386
+
387
+	   POST /containers/e90e34656806/stop?t=5 HTTP/1.1
388
+	   
389
+	**Example response**:
390
+
391
+	.. sourcecode:: http
392
+
393
+	   HTTP/1.1 204 OK
394
+	   	
395
+	:query t: number of seconds to wait before killing the container
396
+	:statuscode 204: no error
397
+	:statuscode 404: no such container
398
+	:statuscode 500: server error
399
+
400
+
401
+Restart a container
402
+*******************
403
+
404
+.. http:post:: /containers/(id)/restart
405
+
406
+	Restart the container ``id``
407
+
408
+	**Example request**:
409
+
410
+	.. sourcecode:: http
411
+
412
+	   POST /containers/e90e34656806/restart?t=5 HTTP/1.1
413
+	   
414
+	**Example response**:
415
+
416
+	.. sourcecode:: http
417
+
418
+	   HTTP/1.1 204 OK
419
+	   	
420
+	:query t: number of seconds to wait before killing the container
421
+	:statuscode 204: no error
422
+	:statuscode 404: no such container
423
+	:statuscode 500: server error
424
+
425
+
426
+Kill a container
427
+****************
428
+
429
+.. http:post:: /containers/(id)/kill
430
+
431
+	Kill the container ``id``
432
+
433
+	**Example request**:
434
+
435
+	.. sourcecode:: http
436
+
437
+	   POST /containers/e90e34656806/kill HTTP/1.1
438
+	   
439
+	**Example response**:
440
+
441
+	.. sourcecode:: http
442
+
443
+	   HTTP/1.1 204 OK
444
+	   	
445
+	:statuscode 204: no error
446
+	:statuscode 404: no such container
447
+	:statuscode 500: server error
448
+
449
+
450
+Attach to a container
451
+*********************
452
+
453
+.. http:post:: /containers/(id)/attach
454
+
455
+	Attach to the container ``id``
456
+
457
+	**Example request**:
458
+
459
+	.. sourcecode:: http
460
+
461
+	   POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
462
+	   
463
+	**Example response**:
464
+
465
+	.. sourcecode:: http
466
+
467
+	   HTTP/1.1 200 OK
468
+	   Content-Type: application/vnd.docker.raw-stream
469
+
470
+	   {{ PREFIXED STREAM }} See :doc:`attach_api_1.6`
471
+	   	
472
+	:query logs: 1/True/true or 0/False/false, return logs. Default false
473
+	:query stream: 1/True/true or 0/False/false, return stream. Default false
474
+	:query stdin: 1/True/true or 0/False/false, if stream=true, attach to stdin. Default false
475
+	:query stdout: 1/True/true or 0/False/false, if logs=true, return stdout log, if stream=true, attach to stdout. Default false
476
+	:query stderr: 1/True/true or 0/False/false, if logs=true, return stderr log, if stream=true, attach to stderr. Default false
477
+	:statuscode 200: no error
478
+	:statuscode 400: bad parameter
479
+	:statuscode 404: no such container
480
+	:statuscode 500: server error
481
+
482
+
483
+Wait a container
484
+****************
485
+
486
+.. http:post:: /containers/(id)/wait
487
+
488
+	Block until container ``id`` stops, then returns the exit code
489
+
490
+	**Example request**:
491
+
492
+	.. sourcecode:: http
493
+
494
+	   POST /containers/16253994b7c4/wait HTTP/1.1
495
+	   
496
+	**Example response**:
497
+
498
+	.. sourcecode:: http
499
+
500
+	   HTTP/1.1 200 OK
501
+	   Content-Type: application/json
502
+
503
+	   {"StatusCode":0}
504
+	   	
505
+	:statuscode 200: no error
506
+	:statuscode 404: no such container
507
+	:statuscode 500: server error
508
+
509
+
510
+Remove a container
511
+*******************
512
+
513
+.. http:delete:: /containers/(id)
514
+
515
+	Remove the container ``id`` from the filesystem
516
+
517
+	**Example request**:
518
+
519
+        .. sourcecode:: http
520
+
521
+           DELETE /containers/16253994b7c4?v=1 HTTP/1.1
522
+
523
+        **Example response**:
524
+
525
+        .. sourcecode:: http
526
+
527
+	   HTTP/1.1 204 OK
528
+
529
+	:query v: 1/True/true or 0/False/false, Remove the volumes associated to the container. Default false
530
+        :statuscode 204: no error
531
+	:statuscode 400: bad parameter
532
+        :statuscode 404: no such container
533
+        :statuscode 500: server error
534
+
535
+
536
+Copy files or folders from a container
537
+**************************************
538
+
539
+.. http:post:: /containers/(id)/copy
540
+
541
+	Copy files or folders of container ``id``
542
+
543
+	**Example request**:
544
+
545
+	.. sourcecode:: http
546
+
547
+	   POST /containers/4fa6e0f0c678/copy HTTP/1.1
548
+	   Content-Type: application/json
549
+
550
+	   {
551
+		"Resource":"test.txt"
552
+	   }
553
+
554
+	**Example response**:
555
+
556
+	.. sourcecode:: http
557
+
558
+	   HTTP/1.1 200 OK
559
+	   Content-Type: application/octet-stream
560
+	   
561
+	   {{ STREAM }}
562
+
563
+	:statuscode 200: no error
564
+	:statuscode 404: no such container
565
+	:statuscode 500: server error
566
+
567
+
568
+2.2 Images
569
+----------
570
+
571
+List Images
572
+***********
573
+
574
+.. http:get:: /images/(format)
575
+
576
+	List images ``format`` could be json or viz (json default)
577
+
578
+	**Example request**:
579
+
580
+	.. sourcecode:: http
581
+
582
+	   GET /images/json?all=0 HTTP/1.1
583
+
584
+	**Example response**:
585
+
586
+	.. sourcecode:: http
587
+
588
+	   HTTP/1.1 200 OK
589
+	   Content-Type: application/json
590
+	   
591
+	   [
592
+		{
593
+			"Repository":"base",
594
+			"Tag":"ubuntu-12.10",
595
+			"Id":"b750fe79269d",
596
+			"Created":1364102658,
597
+			"Size":24653,
598
+			"VirtualSize":180116135
599
+		},
600
+		{
601
+			"Repository":"base",
602
+			"Tag":"ubuntu-quantal",
603
+			"Id":"b750fe79269d",
604
+			"Created":1364102658,
605
+			"Size":24653,
606
+			"VirtualSize":180116135
607
+		}
608
+	   ]
609
+
610
+
611
+	**Example request**:
612
+
613
+	.. sourcecode:: http
614
+
615
+	   GET /images/viz HTTP/1.1
616
+
617
+	**Example response**:
618
+
619
+	.. sourcecode:: http
620
+
621
+	   HTTP/1.1 200 OK
622
+	   Content-Type: text/plain
623
+
624
+	   digraph docker {
625
+	   "d82cbacda43a" -> "074be284591f"
626
+	   "1496068ca813" -> "08306dc45919"
627
+	   "08306dc45919" -> "0e7893146ac2"
628
+	   "b750fe79269d" -> "1496068ca813"
629
+	   base -> "27cf78414709" [style=invis]
630
+	   "f71189fff3de" -> "9a33b36209ed"
631
+	   "27cf78414709" -> "b750fe79269d"
632
+	   "0e7893146ac2" -> "d6434d954665"
633
+	   "d6434d954665" -> "d82cbacda43a"
634
+	   base -> "e9aa60c60128" [style=invis]
635
+	   "074be284591f" -> "f71189fff3de"
636
+	   "b750fe79269d" [label="b750fe79269d\nbase",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
637
+	   "e9aa60c60128" [label="e9aa60c60128\nbase2",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
638
+	   "9a33b36209ed" [label="9a33b36209ed\ntest",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
639
+	   base [style=invisible]
640
+	   }
641
+ 
642
+	:query all: 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default
643
+	:statuscode 200: no error
644
+	:statuscode 400: bad parameter
645
+	:statuscode 500: server error
646
+
647
+
648
+Create an image
649
+***************
650
+
651
+.. http:post:: /images/create
652
+
653
+	Create an image, either by pull it from the registry or by importing it
654
+
655
+	**Example request**:
656
+
657
+        .. sourcecode:: http
658
+
659
+           POST /images/create?fromImage=base HTTP/1.1
660
+
661
+        **Example response**:
662
+
663
+        .. sourcecode:: http
664
+
665
+           HTTP/1.1 200 OK
666
+	   Content-Type: application/json
667
+
668
+	   {"status":"Pulling..."}
669
+	   {"status":"Pulling", "progress":"1/? (n/a)"}
670
+	   {"error":"Invalid..."}
671
+	   ...
672
+
673
+	When using this endpoint to pull an image from the registry,
674
+	the ``X-Registry-Auth`` header can be used to include a
675
+	base64-encoded AuthConfig object.
676
+
677
+        :query fromImage: name of the image to pull
678
+	:query fromSrc: source to import, - means stdin
679
+        :query repo: repository
680
+	:query tag: tag
681
+	:query registry: the registry to pull from
682
+        :statuscode 200: no error
683
+        :statuscode 500: server error
684
+
685
+
686
+Insert a file in an image
687
+*************************
688
+
689
+.. http:post:: /images/(name)/insert
690
+
691
+	Insert a file from ``url`` in the image ``name`` at ``path``
692
+
693
+	**Example request**:
694
+
695
+        .. sourcecode:: http
696
+
697
+           POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
698
+
699
+	**Example response**:
700
+
701
+        .. sourcecode:: http
702
+
703
+           HTTP/1.1 200 OK
704
+	   Content-Type: application/json
705
+
706
+	   {"status":"Inserting..."}
707
+	   {"status":"Inserting", "progress":"1/? (n/a)"}
708
+	   {"error":"Invalid..."}
709
+	   ...
710
+
711
+	:statuscode 200: no error
712
+        :statuscode 500: server error
713
+
714
+
715
+Inspect an image
716
+****************
717
+
718
+.. http:get:: /images/(name)/json
719
+
720
+	Return low-level information on the image ``name``
721
+
722
+	**Example request**:
723
+
724
+	.. sourcecode:: http
725
+
726
+	   GET /images/base/json HTTP/1.1
727
+
728
+	**Example response**:
729
+
730
+        .. sourcecode:: http
731
+
732
+           HTTP/1.1 200 OK
733
+	   Content-Type: application/json
734
+
735
+	   {
736
+		"id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
737
+		"parent":"27cf784147099545",
738
+		"created":"2013-03-23T22:24:18.818426-07:00",
739
+		"container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
740
+		"container_config":
741
+			{
742
+				"Hostname":"",
743
+				"User":"",
744
+				"Memory":0,
745
+				"MemorySwap":0,
746
+				"AttachStdin":false,
747
+				"AttachStdout":false,
748
+				"AttachStderr":false,
749
+				"PortSpecs":null,
750
+				"Tty":true,
751
+				"OpenStdin":true,
752
+				"StdinOnce":false,
753
+				"Env":null,
754
+				"Cmd": ["/bin/bash"]
755
+				,"Dns":null,
756
+				"Image":"base",
757
+				"Volumes":null,
758
+				"VolumesFrom":"",
759
+				"WorkingDir":""
760
+			},
761
+		"Size": 6824592
762
+	   }
763
+
764
+	:statuscode 200: no error
765
+	:statuscode 404: no such image
766
+        :statuscode 500: server error
767
+
768
+
769
+Get the history of an image
770
+***************************
771
+
772
+.. http:get:: /images/(name)/history
773
+
774
+        Return the history of the image ``name``
775
+
776
+        **Example request**:
777
+
778
+        .. sourcecode:: http
779
+
780
+           GET /images/base/history HTTP/1.1
781
+
782
+        **Example response**:
783
+
784
+        .. sourcecode:: http
785
+
786
+           HTTP/1.1 200 OK
787
+	   Content-Type: application/json
788
+
789
+	   [
790
+		{
791
+			"Id":"b750fe79269d",
792
+			"Created":1364102658,
793
+			"CreatedBy":"/bin/bash"
794
+		},
795
+		{
796
+			"Id":"27cf78414709",
797
+			"Created":1364068391,
798
+			"CreatedBy":""
799
+		}
800
+	   ]
801
+
802
+        :statuscode 200: no error
803
+        :statuscode 404: no such image
804
+        :statuscode 500: server error
805
+
806
+
807
+Push an image on the registry
808
+*****************************
809
+
810
+.. http:post:: /images/(name)/push
811
+
812
+   Push the image ``name`` on the registry
813
+
814
+   **Example request**:
815
+
816
+   .. sourcecode:: http
817
+
818
+      POST /images/test/push HTTP/1.1
819
+
820
+   **Example response**:
821
+
822
+   .. sourcecode:: http
823
+
824
+    HTTP/1.1 200 OK
825
+    Content-Type: application/json
826
+
827
+   {"status":"Pushing..."}
828
+   {"status":"Pushing", "progress":"1/? (n/a)"}
829
+   {"error":"Invalid..."}
830
+   ...
831
+
832
+	The ``X-Registry-Auth`` header can be used to include a
833
+	base64-encoded AuthConfig object.
834
+
835
+   :query registry: the registry you wan to push, optional
836
+   :statuscode 200: no error
837
+        :statuscode 404: no such image
838
+        :statuscode 500: server error
839
+
840
+
841
+Tag an image into a repository
842
+******************************
843
+
844
+.. http:post:: /images/(name)/tag
845
+
846
+	Tag the image ``name`` into a repository
847
+
848
+        **Example request**:
849
+
850
+        .. sourcecode:: http
851
+			
852
+	   POST /images/test/tag?repo=myrepo&force=0 HTTP/1.1
853
+
854
+	**Example response**:
855
+
856
+        .. sourcecode:: http
857
+
858
+           HTTP/1.1 200 OK
859
+
860
+	:query repo: The repository to tag in
861
+	:query force: 1/True/true or 0/False/false, default false
862
+	:statuscode 200: no error
863
+	:statuscode 400: bad parameter
864
+	:statuscode 404: no such image
865
+	:statuscode 409: conflict
866
+        :statuscode 500: server error
867
+
868
+
869
+Remove an image
870
+***************
871
+
872
+.. http:delete:: /images/(name)
873
+
874
+	Remove the image ``name`` from the filesystem 
875
+	
876
+	**Example request**:
877
+
878
+	.. sourcecode:: http
879
+
880
+	   DELETE /images/test HTTP/1.1
881
+
882
+	**Example response**:
883
+
884
+        .. sourcecode:: http
885
+
886
+	   HTTP/1.1 200 OK
887
+	   Content-type: application/json
888
+
889
+	   [
890
+	    {"Untagged":"3e2f21a89f"},
891
+	    {"Deleted":"3e2f21a89f"},
892
+	    {"Deleted":"53b4f83ac9"}
893
+	   ]
894
+
895
+	:statuscode 200: no error
896
+        :statuscode 404: no such image
897
+	:statuscode 409: conflict
898
+        :statuscode 500: server error
899
+
900
+
901
+Search images
902
+*************
903
+
904
+.. http:get:: /images/search
905
+
906
+	Search for an image in the docker index
907
+	
908
+	**Example request**:
909
+
910
+        .. sourcecode:: http
911
+
912
+           GET /images/search?term=sshd HTTP/1.1
913
+
914
+	**Example response**:
915
+
916
+	.. sourcecode:: http
917
+
918
+	   HTTP/1.1 200 OK
919
+	   Content-Type: application/json
920
+	   
921
+	   [
922
+		{
923
+			"Name":"cespare/sshd",
924
+			"Description":""
925
+		},
926
+		{
927
+			"Name":"johnfuller/sshd",
928
+			"Description":""
929
+		},
930
+		{
931
+			"Name":"dhrp/mongodb-sshd",
932
+			"Description":""
933
+		}
934
+	   ]
935
+
936
+	   :query term: term to search
937
+	   :statuscode 200: no error
938
+	   :statuscode 500: server error
939
+
940
+
941
+2.3 Misc
942
+--------
943
+
944
+Build an image from Dockerfile via stdin
945
+****************************************
946
+
947
+.. http:post:: /build
948
+
949
+   Build an image from Dockerfile via stdin
950
+
951
+   **Example request**:
952
+
953
+   .. sourcecode:: http
954
+
955
+      POST /build HTTP/1.1
956
+
957
+      {{ STREAM }}
958
+
959
+   **Example response**:
960
+
961
+   .. sourcecode:: http
962
+
963
+      HTTP/1.1 200 OK
964
+
965
+      {{ STREAM }}
966
+
967
+
968
+       The stream must be a tar archive compressed with one of the following algorithms:
969
+       identity (no compression), gzip, bzip2, xz. The archive must include a file called
970
+       `Dockerfile` at its root. It may include any number of other files, which will be
971
+       accessible in the build context (See the ADD build command).
972
+
973
+       The Content-type header should be set to "application/tar".
974
+
975
+	:query t: repository name (and optionally a tag) to be applied to the resulting image in case of success
976
+	:query q: suppress verbose build output
977
+    :query nocache: do not use the cache when building the image
978
+	:statuscode 200: no error
979
+    :statuscode 500: server error
980
+
981
+
982
+Check auth configuration
983
+************************
984
+
985
+.. http:post:: /auth
986
+
987
+        Get the default username and email
988
+
989
+        **Example request**:
990
+
991
+        .. sourcecode:: http
992
+
993
+           POST /auth HTTP/1.1
994
+	   Content-Type: application/json
995
+
996
+	   {
997
+		"username":"hannibal",
998
+		"password:"xxxx",
999
+		"email":"hannibal@a-team.com",
1000
+		"serveraddress":"https://index.docker.io/v1/"
1001
+	   }
1002
+
1003
+        **Example response**:
1004
+
1005
+        .. sourcecode:: http
1006
+
1007
+           HTTP/1.1 200 OK
1008
+
1009
+        :statuscode 200: no error
1010
+        :statuscode 204: no error
1011
+        :statuscode 500: server error
1012
+
1013
+
1014
+Display system-wide information
1015
+*******************************
1016
+
1017
+.. http:get:: /info
1018
+
1019
+	Display system-wide information
1020
+	
1021
+	**Example request**:
1022
+
1023
+        .. sourcecode:: http
1024
+
1025
+           GET /info HTTP/1.1
1026
+
1027
+        **Example response**:
1028
+
1029
+        .. sourcecode:: http
1030
+
1031
+           HTTP/1.1 200 OK
1032
+	   Content-Type: application/json
1033
+
1034
+	   {
1035
+		"Containers":11,
1036
+		"Images":16,
1037
+		"Debug":false,
1038
+		"NFd": 11,
1039
+		"NGoroutines":21,
1040
+		"MemoryLimit":true,
1041
+		"SwapLimit":false,
1042
+		"IPv4Forwarding":true
1043
+	   }
1044
+
1045
+        :statuscode 200: no error
1046
+        :statuscode 500: server error
1047
+
1048
+
1049
+Show the docker version information
1050
+***********************************
1051
+
1052
+.. http:get:: /version
1053
+
1054
+	Show the docker version information
1055
+
1056
+	**Example request**:
1057
+
1058
+        .. sourcecode:: http
1059
+
1060
+           GET /version HTTP/1.1
1061
+
1062
+        **Example response**:
1063
+
1064
+        .. sourcecode:: http
1065
+
1066
+           HTTP/1.1 200 OK
1067
+	   Content-Type: application/json
1068
+
1069
+	   {
1070
+		"Version":"0.2.2",
1071
+		"GitCommit":"5a2a5cc+CHANGES",
1072
+		"GoVersion":"go1.0.3"
1073
+	   }
1074
+
1075
+        :statuscode 200: no error
1076
+	:statuscode 500: server error
1077
+
1078
+
1079
+Create a new image from a container's changes
1080
+*********************************************
1081
+
1082
+.. http:post:: /commit
1083
+
1084
+    Create a new image from a container's changes
1085
+
1086
+    **Example request**:
1087
+
1088
+    .. sourcecode:: http
1089
+
1090
+        POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
1091
+
1092
+    **Example response**:
1093
+
1094
+    .. sourcecode:: http
1095
+
1096
+        HTTP/1.1 201 OK
1097
+	    Content-Type: application/vnd.docker.raw-stream
1098
+
1099
+        {"Id":"596069db4bf5"}
1100
+
1101
+    :query container: source container
1102
+    :query repo: repository
1103
+    :query tag: tag
1104
+    :query m: commit message
1105
+    :query author: author (eg. "John Hannibal Smith <hannibal@a-team.com>")
1106
+    :query run: config automatically applied when the image is run. (ex: {"Cmd": ["cat", "/world"], "PortSpecs":["22"]})
1107
+    :statuscode 201: no error
1108
+    :statuscode 404: no such container
1109
+    :statuscode 500: server error
1110
+
1111
+
1112
+Monitor Docker's events
1113
+***********************
1114
+
1115
+.. http:get:: /events
1116
+
1117
+	Get events from docker, either in real time via streaming, or via polling (using `since`)
1118
+
1119
+	**Example request**:
1120
+
1121
+	.. sourcecode:: http
1122
+
1123
+           POST /events?since=1374067924
1124
+
1125
+        **Example response**:
1126
+
1127
+        .. sourcecode:: http
1128
+
1129
+           HTTP/1.1 200 OK
1130
+	   Content-Type: application/json
1131
+
1132
+	   {"status":"create","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
1133
+	   {"status":"start","id":"dfdf82bd3881","from":"base:latest","time":1374067924}
1134
+	   {"status":"stop","id":"dfdf82bd3881","from":"base:latest","time":1374067966}
1135
+	   {"status":"destroy","id":"dfdf82bd3881","from":"base:latest","time":1374067970}
1136
+
1137
+	:query since: timestamp used for polling
1138
+        :statuscode 200: no error
1139
+        :statuscode 500: server error
1140
+
1141
+
1142
+3. Going further
1143
+================
1144
+
1145
+3.1 Inside 'docker run'
1146
+-----------------------
1147
+
1148
+Here are the steps of 'docker run' :
1149
+
1150
+* Create the container
1151
+* If the status code is 404, it means the image doesn't exists:
1152
+        * Try to pull it
1153
+        * Then retry to create the container
1154
+* Start the container
1155
+* If you are not in detached mode:
1156
+        * Attach to the container, using logs=1 (to have stdout and stderr from the container's start) and stream=1
1157
+* If in detached mode or only stdin is attached:
1158
+	* Display the container's id
1159
+
1160
+
1161
+3.2 Hijacking
1162
+-------------
1163
+
1164
+In this version of the API, /attach, uses hijacking to transport stdin, stdout and stderr on the same socket. This might change in the future.
1165
+
1166
+3.3 CORS Requests
1167
+-----------------
1168
+
1169
+To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
1170
+
1171
+.. code-block:: bash
1172
+
1173
+   docker -d -H="192.168.1.9:4243" -api-enable-cors
1174
+