Browse code

* Remote API: updated docs for 1.3

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