Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e99a99eb6e | ||
|
|
df9712f1c8 | ||
|
|
5c56b597a9 | ||
|
|
f712e10cb2 | ||
|
|
8a851af5e6 | ||
|
|
3b89d13aaf | ||
|
|
16225c473f | ||
|
|
dd2f0d89bf | ||
|
|
0b57e4483a | ||
|
|
f2dc49292f | ||
|
|
a7ace535c3 | ||
|
|
c99e8de5a4 | ||
|
|
c06aa62bda | ||
|
|
9ba998312d | ||
|
|
7d68afb2d2 | ||
|
|
bfdf1839e0 | ||
|
|
5dc86d7bca | ||
|
|
f35491190a | ||
|
|
10e37198aa | ||
|
|
950d0312dc | ||
|
|
c8ec36d1b9 | ||
|
|
97a2dc96f2 | ||
|
|
88b6ea993d | ||
|
|
d4f7039793 | ||
|
|
4399f65fb8 | ||
|
|
2d85a20c71 | ||
|
|
c01d17d77d | ||
|
|
ed0ba04da6 | ||
|
|
b15cfd3530 | ||
|
|
a438d505ba | ||
|
|
5eb590e79d | ||
|
|
bdc79ac8b2 | ||
|
|
a97d858b2a | ||
|
|
e592f1b298 | ||
|
|
513a567483 | ||
|
|
faf103e6ec | ||
|
|
e608296bc6 | ||
|
|
4ebe2cf348 | ||
|
|
422378cb85 | ||
|
|
594c818d85 | ||
|
|
d86898b014 | ||
|
|
be087c9c82 | ||
|
|
9cc8b72a38 | ||
|
|
3425c1b84c | ||
|
|
1c509f4350 | ||
|
|
48833c7b07 | ||
|
|
f385f1860b | ||
|
|
7df6c4b9ad | ||
|
|
8f6b6d5784 | ||
|
|
0fc11699ab | ||
|
|
9332c00ca5 | ||
|
|
fd9ad1a194 | ||
|
|
6ae3305040 | ||
|
|
cc0e091a6b | ||
|
|
dfc076a123 | ||
|
|
f6e1055727 | ||
|
|
6057e6ad70 | ||
|
|
ca39f15fa3 | ||
|
|
7953d1becb | ||
|
|
f4b41e1a6c | ||
|
|
4bc3328e80 | ||
|
|
ebe17f57ff | ||
|
|
ee05f97c9a | ||
|
|
78c02d038f | ||
|
|
bc823acc25 | ||
|
|
c21c5afe00 | ||
|
|
1ae54707a0 | ||
|
|
ede1e6d475 | ||
|
|
e701dce339 | ||
|
|
a93a87f64a | ||
|
|
7aba68cd54 | ||
|
|
dfc64d157a | ||
|
|
a41384ad73 | ||
|
|
ed7a4236b3 | ||
|
|
040c3b50d0 | ||
|
|
8b3519c5f7 | ||
|
|
ec559c02b8 | ||
|
|
2e4d4c9f60 | ||
|
|
b8d52ec266 | ||
|
|
b5da816487 | ||
|
|
3bae188b8d | ||
|
|
8165e51ecc | ||
|
|
9a15db21a6 | ||
|
|
58a1c5720a | ||
|
|
bc172e5e5f | ||
|
|
6745bdd0b3 | ||
|
|
5714f0a74e | ||
|
|
ce43f4af1c | ||
|
|
5d1609f5a2 | ||
|
|
4714f102d7 | ||
|
|
a675da65e9 | ||
|
|
e39755666b | ||
|
|
9adba5e2e6 | ||
|
|
5c1af383eb | ||
|
|
c81662eae4 | ||
|
|
8ea9ccf3a7 | ||
|
|
74a2b13687 | ||
|
|
4e7f2b757e | ||
|
|
2bba279cf1 | ||
|
|
56da77a548 | ||
|
|
494b575213 | ||
|
|
c383d59880 | ||
|
|
416fdaa3d5 | ||
|
|
2b0ebf5d32 | ||
|
|
f236e62d9d | ||
|
|
964e826a9b | ||
|
|
49673fc45c | ||
|
|
3342bdb331 | ||
|
|
1d02a7ffb6 | ||
|
|
788935175e | ||
|
|
32663bf431 | ||
|
|
e3be2e959b | ||
|
|
67f1e3f5ed | ||
|
|
23ea9b8968 | ||
|
|
921c6994b1 | ||
|
|
ea12588524 | ||
|
|
e8ad82f9ba | ||
|
|
6e2e4cad73 | ||
|
|
2e0e455fa6 | ||
|
|
d93742fe9a | ||
|
|
2e3b660dd0 | ||
|
|
0bd534adcf | ||
|
|
e59dd2c62c | ||
|
|
25be79208a | ||
|
|
2a3b91e3b6 | ||
|
|
221ee504aa | ||
|
|
64e74cefb7 | ||
|
|
eb4a0271fb | ||
|
|
cfec1c3e1b | ||
|
|
2b5386f039 | ||
|
|
a0eec14c7d | ||
|
|
54f9cdb0c3 | ||
|
|
d6fb313220 | ||
|
|
0aa2470c76 | ||
|
|
edc68f84f3 | ||
|
|
0089dd05e9 | ||
|
|
51f6c4a737 | ||
|
|
cd209f406e | ||
|
|
f4eaec3e1e | ||
|
|
b083418257 | ||
|
|
5794857f7a | ||
|
|
e7f3f6fa5a | ||
|
|
1b0fd7ead3 | ||
|
|
a926cd4d88 | ||
|
|
aa5671411b | ||
|
|
f8dfd0aa5e | ||
|
|
3dbf9c6560 | ||
|
|
de563a3ea3 | ||
|
|
9cf2b41c05 | ||
|
|
f310b875f8 | ||
|
|
ac14c463d5 | ||
|
|
578e888915 | ||
|
|
5231bf3653 | ||
|
|
8af945f353 | ||
|
|
d0e8ca1257 | ||
|
|
5a934fc923 | ||
|
|
c766d064ac | ||
|
|
0356081c0a | ||
|
|
6e8bfc8d12 | ||
|
|
18e91d5f85 | ||
|
|
1004d57b85 | ||
|
|
f9e4ef5eb0 | ||
|
|
eefbadd230 | ||
|
|
bc21b3ebf0 | ||
|
|
608fb2a21e | ||
|
|
92cbb7cc80 | ||
|
|
45050d9887 | ||
|
|
75a0052e64 | ||
|
|
c8efd08384 | ||
|
|
454cd147fb | ||
|
|
e41507bde2 | ||
|
|
599f85d4e4 | ||
|
|
5756ba9bc4 | ||
|
|
193a7e1dc1 | ||
|
|
0900d3b7a6 | ||
|
|
24dd50490a | ||
|
|
5ae8c7a985 | ||
|
|
9b57f9187b | ||
|
|
50e45b485f | ||
|
|
2051ebc0eb | ||
|
|
080243f040 | ||
|
|
933b9d44e1 | ||
|
|
44b3e8d51b | ||
|
|
9bf8ad741f | ||
|
|
9913ebbe21 | ||
|
|
c7a48e91d8 | ||
|
|
2cbf2200ac | ||
|
|
bac5772312 | ||
|
|
a6e5a397bd | ||
|
|
364f48d6c7 | ||
|
|
4174e7aa7a | ||
|
|
eb38750d99 | ||
|
|
cd0fef633c | ||
|
|
d0c73c28df | ||
|
|
8e6c249e48 | ||
|
|
752f99e8a1 | ||
|
|
a909223ee2 | ||
|
|
8ff271fc74 | ||
|
|
9dfac1dd65 | ||
|
|
a8a6848ce0 | ||
|
|
9232d1ef62 | ||
|
|
90483dc912 | ||
|
|
6bdb6f226b | ||
|
|
2ac1141980 | ||
|
|
1104d443cc | ||
|
|
49044a9608 | ||
|
|
71d2ff4946 | ||
|
|
474191dd7b | ||
|
|
637eceb6a7 | ||
|
|
976428f505 | ||
|
|
affe7caf78 | ||
|
|
941e3e2ef0 | ||
|
|
b7937e268f | ||
|
|
5a411fa38e | ||
|
|
bf26ae03cf | ||
|
|
3363cd5cd0 | ||
|
|
5c49a61353 | ||
|
|
f83c31e188 | ||
|
|
8f36467107 | ||
|
|
73e79a3310 | ||
|
|
34cf976866 | ||
|
|
e832b01349 | ||
|
|
26c8eae6fe | ||
|
|
d40efc4648 | ||
|
|
5705a49308 | ||
|
|
65185a565b | ||
|
|
1bb8f60d5a | ||
|
|
1d01189f04 | ||
|
|
8e49cb453f | ||
|
|
40f1e4edbe | ||
|
|
1267e15b0f | ||
|
|
eb9fef2c42 | ||
|
|
43b346d93b | ||
|
|
d918c7d9de | ||
|
|
e962e9edcf | ||
|
|
b7a62f1f1b | ||
|
|
2e5d1a2d48 | ||
|
|
fac0d87d00 | ||
|
|
a839b36e55 | ||
|
|
316c8328aa | ||
|
|
e8db031112 | ||
|
|
59b785a282 | ||
|
|
1a1daca621 | ||
|
|
837be914ca | ||
|
|
f44eac49fa | ||
|
|
0acdef4549 | ||
|
|
7d8ef90ccb | ||
|
|
91520838fc | ||
|
|
ada0e1fb08 | ||
|
|
33d97e81eb | ||
|
|
019324015b | ||
|
|
72d278fdac | ||
|
|
05d7f85af9 | ||
|
|
7fba358ae2 | ||
|
|
9f1fc40a64 | ||
|
|
3be7bc38e0 | ||
|
|
31c66d5a00 | ||
|
|
e7d36c9590 | ||
|
|
3e8626c4a1 | ||
|
|
e14dd4d33e | ||
|
|
87a69e6753 | ||
|
|
f64dbdbe3a | ||
|
|
2b5553144a | ||
|
|
e43ef364cb | ||
|
|
08a87d4b3b | ||
|
|
90f372af5c | ||
|
|
3ec29eb5da | ||
|
|
3a20e4e15d | ||
|
|
fd97190ee7 | ||
|
|
70480ce7bc | ||
|
|
bf7d6cbb4a | ||
|
|
c059785ffb | ||
|
|
a0f5fb7394 | ||
|
|
ad33e9f388 | ||
|
|
1d1d81b0bc | ||
|
|
f3d2969560 | ||
|
|
758ea61b77 | ||
|
|
4388bef996 | ||
|
|
e2b8ee2723 | ||
|
|
07dc0a5120 | ||
|
|
d3125d8570 | ||
|
|
283ebf3ff9 | ||
|
|
4c174e0bfb | ||
|
|
57a6c83547 | ||
|
|
cfc7684b7d | ||
|
|
be49f0a118 | ||
|
|
66a9d06d9f | ||
|
|
6940cf1ecd | ||
|
|
4e0cdc016a | ||
|
|
8a8109648a | ||
|
|
dc8b359319 | ||
|
|
dea29e7c99 | ||
|
|
ab6379b3e0 | ||
|
|
f7fed2ea5f | ||
|
|
35e87ee571 | ||
|
|
ab3893ff4d | ||
|
|
1277dca335 | ||
|
|
ba9aef6f2c | ||
|
|
dd619d2bd6 | ||
|
|
1e2ef274cd | ||
|
|
bcb5e36dd9 | ||
|
|
19121c16d9 | ||
|
|
27ee261e60 | ||
|
|
da3962266a | ||
|
|
e93afcdd2b | ||
|
|
dd1b9e38e9 | ||
|
|
96bc9ea7c1 | ||
|
|
16c8a10ef9 | ||
|
|
5dcd11be16 | ||
|
|
dc91a7b641 | ||
|
|
11998ae7d6 | ||
|
|
1cf9c80e97 | ||
|
|
6dbcdd3ed5 | ||
|
|
9632cf09bf | ||
|
|
96ab3c540d | ||
|
|
ff964d327d | ||
|
|
4b8688f1e5 | ||
|
|
55b5889a0f | ||
|
|
dd4c6f6a09 | ||
|
|
6058261a26 | ||
|
|
b461e4607d | ||
|
|
d399f72098 | ||
|
|
c9e1c65c64 | ||
|
|
3042f11666 | ||
|
|
e5e47c9862 | ||
|
|
1c5083315d | ||
|
|
27a137ccab | ||
|
|
7cc294e777 | ||
|
|
a20dcfb049 | ||
|
|
06b53e3fc7 | ||
|
|
8f9dd86146 | ||
|
|
ebba0a6024 | ||
|
|
c9236d99d2 | ||
|
|
f03c1b8eeb | ||
|
|
6f23e39e6b | ||
|
|
fe0378e9b3 | ||
|
|
96a1d7c645 | ||
|
|
79ee8b46f4 | ||
|
|
55a7a8b8c9 | ||
|
|
b47873c5ac | ||
|
|
adf75d402a | ||
|
|
cb1fdb2f03 | ||
|
|
d1d66b9c5f | ||
|
|
6dacbb451f | ||
|
|
ead9cefadb | ||
|
|
185a2fc55e | ||
|
|
fb8fac6c60 | ||
|
|
b6f288a1ce | ||
|
|
aa9bec96b1 | ||
|
|
11e28842ac | ||
|
|
b16ff9f859 | ||
|
|
348c5c4838 | ||
|
|
8dcc6a0280 | ||
|
|
3b5ad44647 | ||
|
|
5e029f7600 | ||
|
|
52cebe19e5 | ||
|
|
d8d33e8b8b | ||
|
|
b37f7d49d8 | ||
|
|
d67d5dd963 | ||
|
|
273e0d42b7 | ||
|
|
ca497a82ab | ||
|
|
b7226316c7 | ||
|
|
84f41954ae | ||
|
|
54da339b2c | ||
|
|
ac37fcf6f3 | ||
|
|
893c974b08 | ||
|
|
30342efa37 | ||
|
|
6165c246d4 | ||
|
|
72befeef24 | ||
|
|
648c4f198b | ||
|
|
af2a92f22b | ||
|
|
ad2f826a82 | ||
|
|
e095a1572f | ||
|
|
c3dd6e1926 | ||
|
|
67ecd2cb82 | ||
|
|
57d751c377 | ||
|
|
50075106b6 | ||
|
|
2a1f8f6fda | ||
|
|
1c817913ee | ||
|
|
de0a48bd6f | ||
|
|
8589fd6db8 | ||
|
|
2e79719622 | ||
|
|
9bfec5a538 | ||
|
|
a11fc9f067 | ||
|
|
e12a204bcc | ||
|
|
fe014a8e6c | ||
|
|
aa8ea84d11 | ||
|
|
3175e56ad0 | ||
|
|
800d900688 | ||
|
|
1a201d2433 | ||
|
|
750c94efbb | ||
|
|
bd144a64f6 | ||
|
|
2a20e85203 | ||
|
|
5ed4386bbf | ||
|
|
9d3ec7b39f | ||
|
|
e68a23bdc1 | ||
|
|
6cf493bea7 | ||
|
|
3d5633a0a0 | ||
|
|
c4a44f6f0b | ||
|
|
3e29695c1f | ||
|
|
46a9f29bae | ||
|
|
67239957c9 | ||
|
|
d4e62101ab | ||
|
|
4fdf11b2e6 | ||
|
|
cd0f22ef72 | ||
|
|
27d6777376 | ||
|
|
e5c0b31107 | ||
|
|
5cdbd2ed7a | ||
|
|
b44e2e71aa | ||
|
|
73afc6311d | ||
|
|
6127d757a7 | ||
|
|
fb86dcfb17 | ||
|
|
bccf06c748 | ||
|
|
862e223cec | ||
|
|
e1e2ff52fe | ||
|
|
d03edf12e4 | ||
|
|
ec1dfc521c | ||
|
|
5190f7f33a | ||
|
|
873a5aa8e7 | ||
|
|
672d3a6c6c | ||
|
|
a749fb2130 | ||
|
|
25d1bc2c09 | ||
|
|
cc63c1b584 | ||
|
|
145c622aba | ||
|
|
e2516c01b4 | ||
|
|
a3cb18d0f0 | ||
|
|
eca9f9c1a1 | ||
|
|
aee845682f | ||
|
|
e3dbe2f2ba | ||
|
|
193888a2b4 | ||
|
|
9fe8bfb2bc | ||
|
|
fc25973371 | ||
|
|
f9acd605dc | ||
|
|
290b1973a9 | ||
|
|
d7d42ff4fe | ||
|
|
ce9e50f4ee | ||
|
|
ecd1fff9b0 | ||
|
|
b0f12bd5e8 | ||
|
|
5d61ec11e3 | ||
|
|
41cdd9b27f | ||
|
|
ec6b35240e | ||
|
|
c792c0a6c9 | ||
|
|
d9d2540162 | ||
|
|
f5d08fc49c | ||
|
|
b24759af1c | ||
|
|
4d1692726b | ||
|
|
1581ed52ba | ||
|
|
de1a5a75cc | ||
|
|
169ef21de7 | ||
|
|
d0fa6927f8 | ||
|
|
63e8a4ac74 | ||
|
|
459230d3f9 | ||
|
|
070e1aec7e | ||
|
|
3ac68f1966 | ||
|
|
42bcfcc927 | ||
|
|
5ccde4dffc | ||
|
|
dc847001a5 | ||
|
|
639833aaf5 | ||
|
|
8f2a80804c | ||
|
|
78842970cf | ||
|
|
8e7d4cda07 | ||
|
|
5b3ad0023b | ||
|
|
6a1279fb90 | ||
|
|
66910a7602 | ||
|
|
d9bce2defd | ||
|
|
352991bdf4 | ||
|
|
4383d7b603 | ||
|
|
89ae56820a | ||
|
|
17489cac1a | ||
|
|
c1a5318d8e | ||
|
|
b0b690cf23 | ||
|
|
86e83186b5 | ||
|
|
36d610a388 | ||
|
|
50b70eeb68 | ||
|
|
cc0f59742f | ||
|
|
09dd7f14de | ||
|
|
b419699ab8 | ||
|
|
08825fa611 | ||
|
|
02f0c1e46d | ||
|
|
e44f62a95c | ||
|
|
dbfb3eb923 | ||
|
|
e43323221b | ||
|
|
da06349723 | ||
|
|
cff2187a4c | ||
|
|
a078d3c872 | ||
|
|
da5bb4db96 | ||
|
|
1b19939742 | ||
|
|
930e1d8830 | ||
|
|
fa68fe6ff3 | ||
|
|
21a5a6202d | ||
|
|
db60337598 | ||
|
|
c5be64fec4 | ||
|
|
659e846006 | ||
|
|
d8f56352da | ||
|
|
d1a3d020aa | ||
|
|
8807b7dd46 | ||
|
|
cd155a1f25 | ||
|
|
d8887f3488 | ||
|
|
1c841d4fee | ||
|
|
da199846d2 | ||
|
|
bd04d7d475 | ||
|
|
5f93aa0ecf | ||
|
|
05796bed57 | ||
|
|
8a131dffb6 | ||
|
|
79efcb545d | ||
|
|
88dcba3482 | ||
|
|
754609ab69 | ||
|
|
d6ab71f450 | ||
|
|
55edbcd02f | ||
|
|
90dde9beab | ||
|
|
5fc1329b2f | ||
|
|
9c8085a0aa | ||
|
|
507ea757a5 | ||
|
|
7e065aaacd | ||
|
|
0312bbc535 | ||
|
|
a056f1deec | ||
|
|
fdaefe6997 | ||
|
|
88279439af | ||
|
|
2d6a49215c | ||
|
|
a7e14a3065 | ||
|
|
a660cc0d01 | ||
|
|
788d66f409 | ||
|
|
96988a37f5 | ||
|
|
b368d21568 | ||
|
|
c88b763e80 | ||
|
|
ec3c89e57c | ||
|
|
5dcab2d361 | ||
|
|
5f7e98be20 | ||
|
|
d52af3f58f | ||
|
|
063c838c92 | ||
|
|
9632bf2287 | ||
|
|
dede1585ee | ||
|
|
5be7b9af3e | ||
|
|
5183399f50 | ||
|
|
a780b7c6b5 | ||
|
|
0ae778c881 | ||
|
|
1f8b679b18 | ||
|
|
ee5df76579 | ||
|
|
b431720dac | ||
|
|
42ce68894a | ||
|
|
c063fc0238 | ||
|
|
0a9ac63a05 | ||
|
|
6dccdd657f | ||
|
|
34a434616a | ||
|
|
bc9b91e501 | ||
|
|
edbd3da33a | ||
|
|
32e8f9beca | ||
|
|
84ceeaa870 | ||
|
|
cdeaba2acf | ||
|
|
c0b82bd807 | ||
|
|
88e35b6f80 | ||
|
|
6e17cc45ea | ||
|
|
cb9d0fd3bc | ||
|
|
3adf9ce04e | ||
|
|
c2e95997d4 | ||
|
|
808faa6371 | ||
|
|
6f511ac29b | ||
|
|
3dc93e390a | ||
|
|
e2d034e488 | ||
|
|
86205540d8 | ||
|
|
702c3538a4 | ||
|
|
069a7c1e99 | ||
|
|
8281a0fa1c | ||
|
|
3491d7d2f1 | ||
|
|
0809f649d3 | ||
|
|
02a002d264 | ||
|
|
3bfc822578 | ||
|
|
02c291d13b | ||
|
|
b25bcf1a66 | ||
|
|
fe204e6f48 | ||
|
|
2b6ca38728 | ||
|
|
c106ed32ea | ||
|
|
2626d88a21 | ||
|
|
3a0ffbc772 | ||
|
|
555552340d | ||
|
|
13e03a6911 | ||
|
|
fde82f448f | ||
|
|
79b3265ef1 | ||
|
|
fe88b5068d | ||
|
|
f50e40008f | ||
|
|
061f8d12e0 | ||
|
|
38554fc2a7 | ||
|
|
cc7de8df75 | ||
|
|
78f86ea502 | ||
|
|
76a568fc97 | ||
|
|
abf85b2508 | ||
|
|
60fd7d686d | ||
|
|
79fe864d9a | ||
|
|
6f7de49aa8 | ||
|
|
90f6bdd6e4 | ||
|
|
9cc72ff1a9 | ||
|
|
2f14dae83f | ||
|
|
f03ebc20aa | ||
|
|
4b4918f2a7 | ||
|
|
0425f65e63 | ||
|
|
f5fe3ce34e | ||
|
|
d0084ce5f2 | ||
|
|
b38c6929be | ||
|
|
8984aef899 | ||
|
|
b103ac70bf | ||
|
|
1e0738f63f | ||
|
|
f355d33b5f | ||
|
|
2cc22de696 | ||
|
|
12c9b9b3c9 | ||
|
|
a11e61677c | ||
|
|
01f446e908 | ||
|
|
f4a4cfd2cc | ||
|
|
eaa2183d77 | ||
|
|
31d2b258c1 |
@@ -15,3 +15,4 @@ docs/_build
|
|||||||
docs/_static
|
docs/_static
|
||||||
docs/_templates
|
docs/_templates
|
||||||
.gopath/
|
.gopath/
|
||||||
|
.dotcloud
|
||||||
|
|||||||
@@ -19,3 +19,9 @@ Andy Smith <github@anarkystic.com>
|
|||||||
<victor.vieux@dotcloud.com> <dev@vvieux.com>
|
<victor.vieux@dotcloud.com> <dev@vvieux.com>
|
||||||
<dominik@honnef.co> <dominikh@fork-bomb.org>
|
<dominik@honnef.co> <dominikh@fork-bomb.org>
|
||||||
Thatcher Peskens <thatcher@dotcloud.com>
|
Thatcher Peskens <thatcher@dotcloud.com>
|
||||||
|
<ehanchrow@ine.com> <eric.hanchrow@gmail.com>
|
||||||
|
Walter Stanish <walter@pratyeka.org>
|
||||||
|
<daniel@gasienica.ch> <dgasienica@zynga.com>
|
||||||
|
Roberto Hashioka <roberto_hashioka@hotmail.com>
|
||||||
|
Konstantin Pelykh <kpelykh@zettaset.com>
|
||||||
|
David Sissitka <me@dsissitka.com>
|
||||||
|
|||||||
@@ -4,64 +4,110 @@
|
|||||||
# For a list of active project maintainers, see the MAINTAINERS file.
|
# For a list of active project maintainers, see the MAINTAINERS file.
|
||||||
#
|
#
|
||||||
Al Tobey <al@ooyala.com>
|
Al Tobey <al@ooyala.com>
|
||||||
|
Alex Gaynor <alex.gaynor@gmail.com>
|
||||||
Alexey Shamrin <shamrin@gmail.com>
|
Alexey Shamrin <shamrin@gmail.com>
|
||||||
Andrea Luzzardi <aluzzardi@gmail.com>
|
Andrea Luzzardi <aluzzardi@gmail.com>
|
||||||
|
Andreas Tiefenthaler <at@an-ti.eu>
|
||||||
|
Andrew Munsell <andrew@wizardapps.net>
|
||||||
|
Andrews Medina <andrewsmedina@gmail.com>
|
||||||
Andy Rothfusz <github@metaliveblog.com>
|
Andy Rothfusz <github@metaliveblog.com>
|
||||||
Andy Smith <github@anarkystic.com>
|
Andy Smith <github@anarkystic.com>
|
||||||
|
Anthony Bishopric <git@anthonybishopric.com>
|
||||||
Antony Messerli <amesserl@rackspace.com>
|
Antony Messerli <amesserl@rackspace.com>
|
||||||
Barry Allard <barry.allard@gmail.com>
|
Barry Allard <barry.allard@gmail.com>
|
||||||
Brandon Liu <bdon@bdon.org>
|
Brandon Liu <bdon@bdon.org>
|
||||||
Brian McCallister <brianm@skife.org>
|
Brian McCallister <brianm@skife.org>
|
||||||
Bruno Bigras <bigras.bruno@gmail.com>
|
Bruno Bigras <bigras.bruno@gmail.com>
|
||||||
Caleb Spare <cespare@gmail.com>
|
Caleb Spare <cespare@gmail.com>
|
||||||
|
Calen Pennington <cale@edx.org>
|
||||||
Charles Hooper <charles.hooper@dotcloud.com>
|
Charles Hooper <charles.hooper@dotcloud.com>
|
||||||
|
Christopher Currie <codemonkey+github@gmail.com>
|
||||||
Daniel Gasienica <daniel@gasienica.ch>
|
Daniel Gasienica <daniel@gasienica.ch>
|
||||||
Daniel Mizyrycki <daniel.mizyrycki@dotcloud.com>
|
Daniel Mizyrycki <daniel.mizyrycki@dotcloud.com>
|
||||||
Daniel Robinson <gottagetmac@gmail.com>
|
Daniel Robinson <gottagetmac@gmail.com>
|
||||||
Daniel Von Fange <daniel@leancoder.com>
|
Daniel Von Fange <daniel@leancoder.com>
|
||||||
|
Daniel YC Lin <dlin.tw@gmail.com>
|
||||||
|
David Calavera <david.calavera@gmail.com>
|
||||||
|
David Sissitka <me@dsissitka.com>
|
||||||
Dominik Honnef <dominik@honnef.co>
|
Dominik Honnef <dominik@honnef.co>
|
||||||
Don Spaulding <donspauldingii@gmail.com>
|
Don Spaulding <donspauldingii@gmail.com>
|
||||||
Dr Nic Williams <drnicwilliams@gmail.com>
|
Dr Nic Williams <drnicwilliams@gmail.com>
|
||||||
|
Elias Probst <mail@eliasprobst.eu>
|
||||||
|
Eric Hanchrow <ehanchrow@ine.com>
|
||||||
|
Eric Myhre <hash@exultant.us>
|
||||||
|
Erno Hopearuoho <erno.hopearuoho@gmail.com>
|
||||||
Evan Wies <evan@neomantra.net>
|
Evan Wies <evan@neomantra.net>
|
||||||
ezbercih <cem.ezberci@gmail.com>
|
ezbercih <cem.ezberci@gmail.com>
|
||||||
|
Fabrizio Regini <freegenie@gmail.com>
|
||||||
Flavio Castelli <fcastelli@suse.com>
|
Flavio Castelli <fcastelli@suse.com>
|
||||||
Francisco Souza <f@souza.cc>
|
Francisco Souza <f@souza.cc>
|
||||||
Frederick F. Kautz IV <fkautz@alumni.cmu.edu>
|
Frederick F. Kautz IV <fkautz@alumni.cmu.edu>
|
||||||
|
Gabriel Monroy <gabriel@opdemand.com>
|
||||||
|
Gareth Rushgrove <gareth@morethanseven.net>
|
||||||
Guillaume J. Charmes <guillaume.charmes@dotcloud.com>
|
Guillaume J. Charmes <guillaume.charmes@dotcloud.com>
|
||||||
Harley Laue <losinggeneration@gmail.com>
|
Harley Laue <losinggeneration@gmail.com>
|
||||||
Hunter Blanks <hunter@twilio.com>
|
Hunter Blanks <hunter@twilio.com>
|
||||||
Jeff Lindsay <progrium@gmail.com>
|
Jeff Lindsay <progrium@gmail.com>
|
||||||
Jeremy Grosser <jeremy@synack.me>
|
Jeremy Grosser <jeremy@synack.me>
|
||||||
Joffrey F <joffrey@dotcloud.com>
|
Joffrey F <joffrey@dotcloud.com>
|
||||||
|
Johan Euphrosine <proppy@google.com>
|
||||||
John Costa <john.costa@gmail.com>
|
John Costa <john.costa@gmail.com>
|
||||||
|
Jon Wedaman <jweede@gmail.com>
|
||||||
Jonas Pfenniger <jonas@pfenniger.name>
|
Jonas Pfenniger <jonas@pfenniger.name>
|
||||||
Jonathan Rudenberg <jonathan@titanous.com>
|
Jonathan Rudenberg <jonathan@titanous.com>
|
||||||
|
Joseph Anthony Pasquale Holsten <joseph@josephholsten.com>
|
||||||
Julien Barbier <write0@gmail.com>
|
Julien Barbier <write0@gmail.com>
|
||||||
Jérôme Petazzoni <jerome.petazzoni@dotcloud.com>
|
Jérôme Petazzoni <jerome.petazzoni@dotcloud.com>
|
||||||
|
Karan Lyons <karan@karanlyons.com>
|
||||||
|
Keli Hu <dev@keli.hu>
|
||||||
Ken Cochrane <kencochrane@gmail.com>
|
Ken Cochrane <kencochrane@gmail.com>
|
||||||
Kevin J. Lynagh <kevin@keminglabs.com>
|
Kevin J. Lynagh <kevin@keminglabs.com>
|
||||||
|
kim0 <email.ahmedkamal@googlemail.com>
|
||||||
|
Kimbro Staken <kstaken@kstaken.com>
|
||||||
|
Kiran Gangadharan <kiran.daredevil@gmail.com>
|
||||||
|
Konstantin Pelykh <kpelykh@zettaset.com>
|
||||||
Louis Opter <kalessin@kalessin.fr>
|
Louis Opter <kalessin@kalessin.fr>
|
||||||
|
Marco Hennings <marco.hennings@freiheit.com>
|
||||||
|
Marcus Farkas <toothlessgear@finitebox.com>
|
||||||
|
Mark McGranaghan <mmcgrana@gmail.com>
|
||||||
Maxim Treskin <zerthurd@gmail.com>
|
Maxim Treskin <zerthurd@gmail.com>
|
||||||
|
meejah <meejah@meejah.ca>
|
||||||
Michael Crosby <crosby.michael@gmail.com>
|
Michael Crosby <crosby.michael@gmail.com>
|
||||||
|
Mike Gaffney <mike@uberu.com>
|
||||||
Mikhail Sobolev <mss@mawhrin.net>
|
Mikhail Sobolev <mss@mawhrin.net>
|
||||||
|
Nan Monnand Deng <monnand@gmail.com>
|
||||||
Nate Jones <nate@endot.org>
|
Nate Jones <nate@endot.org>
|
||||||
Nelson Chen <crazysim@gmail.com>
|
Nelson Chen <crazysim@gmail.com>
|
||||||
Niall O'Higgins <niallo@unworkable.org>
|
Niall O'Higgins <niallo@unworkable.org>
|
||||||
|
Nick Stenning <nick.stenning@digital.cabinet-office.gov.uk>
|
||||||
|
Nick Stinemates <nick@stinemates.org>
|
||||||
odk- <github@odkurzacz.org>
|
odk- <github@odkurzacz.org>
|
||||||
Paul Bowsher <pbowsher@globalpersonals.co.uk>
|
Paul Bowsher <pbowsher@globalpersonals.co.uk>
|
||||||
Paul Hammond <paul@paulhammond.org>
|
Paul Hammond <paul@paulhammond.org>
|
||||||
|
Phil Spitler <pspitler@gmail.com>
|
||||||
Piotr Bogdan <ppbogdan@gmail.com>
|
Piotr Bogdan <ppbogdan@gmail.com>
|
||||||
|
Renato Riccieri Santos Zannon <renato.riccieri@gmail.com>
|
||||||
|
Rhys Hiltner <rhys@twitch.tv>
|
||||||
Robert Obryk <robryk@gmail.com>
|
Robert Obryk <robryk@gmail.com>
|
||||||
|
Roberto Hashioka <roberto_hashioka@hotmail.com>
|
||||||
|
Ryan Fowler <rwfowler@gmail.com>
|
||||||
Sam Alba <sam.alba@gmail.com>
|
Sam Alba <sam.alba@gmail.com>
|
||||||
|
Sam J Sharpe <sam.sharpe@digital.cabinet-office.gov.uk>
|
||||||
Shawn Siefkas <shawn.siefkas@meredith.com>
|
Shawn Siefkas <shawn.siefkas@meredith.com>
|
||||||
Silas Sewell <silas@sewell.org>
|
Silas Sewell <silas@sewell.org>
|
||||||
Solomon Hykes <solomon@dotcloud.com>
|
Solomon Hykes <solomon@dotcloud.com>
|
||||||
Sridhar Ratnakumar <sridharr@activestate.com>
|
Sridhar Ratnakumar <sridharr@activestate.com>
|
||||||
|
Stefan Praszalowicz <stefan@greplin.com>
|
||||||
Thatcher Peskens <thatcher@dotcloud.com>
|
Thatcher Peskens <thatcher@dotcloud.com>
|
||||||
Thomas Bikeev <thomas.bikeev@mac.com>
|
Thomas Bikeev <thomas.bikeev@mac.com>
|
||||||
|
Thomas Hansen <thomas.hansen@gmail.com>
|
||||||
Tianon Gravi <admwiggin@gmail.com>
|
Tianon Gravi <admwiggin@gmail.com>
|
||||||
Tim Terhorst <mynamewastaken+git@gmail.com>
|
Tim Terhorst <mynamewastaken+git@gmail.com>
|
||||||
Troy Howard <thoward37@gmail.com>
|
Tobias Bieniek <Tobias.Bieniek@gmx.de>
|
||||||
|
Tobias Schwab <tobias.schwab@dynport.de>
|
||||||
|
Tom Hulihan <hulihan.tom159@gmail.com>
|
||||||
unclejack <unclejacksons@gmail.com>
|
unclejack <unclejacksons@gmail.com>
|
||||||
Victor Vieux <victor.vieux@dotcloud.com>
|
Victor Vieux <victor.vieux@dotcloud.com>
|
||||||
Vivek Agarwal <me@vivek.im>
|
Vivek Agarwal <me@vivek.im>
|
||||||
|
Walter Stanish <walter@pratyeka.org>
|
||||||
|
Will Dietz <w@wdtz.org>
|
||||||
|
|||||||
@@ -1,5 +1,92 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.5.2 (2013-08-08)
|
||||||
|
* Builder: Forbid certain paths within docker build ADD
|
||||||
|
- Runtime: Change network range to avoid conflict with EC2 DNS
|
||||||
|
* API: Change daemon to listen on unix socket by default
|
||||||
|
|
||||||
|
## 0.5.1 (2013-07-30)
|
||||||
|
+ API: Docker client now sets useragent (RFC 2616)
|
||||||
|
+ Runtime: Add `ps` args to `docker top`
|
||||||
|
+ Runtime: Add support for container ID files (pidfile like)
|
||||||
|
+ Runtime: Add container=lxc in default env
|
||||||
|
+ Runtime: Support networkless containers with `docker run -n` and `docker -d -b=none`
|
||||||
|
+ API: Add /events endpoint
|
||||||
|
+ Builder: ADD command now understands URLs
|
||||||
|
+ Builder: CmdAdd and CmdEnv now respect Dockerfile-set ENV variables
|
||||||
|
* Hack: Simplify unit tests with helpers
|
||||||
|
* Hack: Improve docker.upstart event
|
||||||
|
* Hack: Add coverage testing into docker-ci
|
||||||
|
* Runtime: Stdout/stderr logs are now stored in the same file as JSON
|
||||||
|
* Runtime: Allocate a /16 IP range by default, with fallback to /24. Try 12 ranges instead of 3.
|
||||||
|
* Runtime: Change .dockercfg format to json and support multiple auth remote
|
||||||
|
- Runtime: Do not override volumes from config
|
||||||
|
- Runtime: Fix issue with EXPOSE override
|
||||||
|
- Builder: Create directories with 755 instead of 700 within ADD instruction
|
||||||
|
|
||||||
|
## 0.5.0 (2013-07-17)
|
||||||
|
+ Runtime: List all processes running inside a container with 'docker top'
|
||||||
|
+ Runtime: Host directories can be mounted as volumes with 'docker run -v'
|
||||||
|
+ Runtime: Containers can expose public UDP ports (eg, '-p 123/udp')
|
||||||
|
+ Runtime: Optionally specify an exact public port (eg. '-p 80:4500')
|
||||||
|
+ Registry: New image naming scheme inspired by Go packaging convention allows arbitrary combinations of registries
|
||||||
|
+ Builder: ENTRYPOINT instruction sets a default binary entry point to a container
|
||||||
|
+ Builder: VOLUME instruction marks a part of the container as persistent data
|
||||||
|
* Builder: 'docker build' displays the full output of a build by default
|
||||||
|
* Runtime: 'docker login' supports additional options
|
||||||
|
- Runtime: Dont save a container's hostname when committing an image.
|
||||||
|
- Registry: Fix issues when uploading images to a private registry
|
||||||
|
|
||||||
|
## 0.4.8 (2013-07-01)
|
||||||
|
+ Builder: New build operation ENTRYPOINT adds an executable entry point to the container.
|
||||||
|
- Runtime: Fix a bug which caused 'docker run -d' to no longer print the container ID.
|
||||||
|
- Tests: Fix issues in the test suite
|
||||||
|
|
||||||
|
## 0.4.7 (2013-06-28)
|
||||||
|
* Registry: easier push/pull to a custom registry
|
||||||
|
* Remote API: the progress bar updates faster when downloading and uploading large files
|
||||||
|
- Remote API: fix a bug in the optional unix socket transport
|
||||||
|
* Runtime: improve detection of kernel version
|
||||||
|
+ Runtime: host directories can be mounted as volumes with 'docker run -b'
|
||||||
|
- Runtime: fix an issue when only attaching to stdin
|
||||||
|
* Runtime: use 'tar --numeric-owner' to avoid uid mismatch across multiple hosts
|
||||||
|
* Hack: improve test suite and dev environment
|
||||||
|
* Hack: remove dependency on unit tests on 'os/user'
|
||||||
|
+ Documentation: add terminology section
|
||||||
|
|
||||||
|
## 0.4.6 (2013-06-22)
|
||||||
|
- Runtime: fix a bug which caused creation of empty images (and volumes) to crash.
|
||||||
|
|
||||||
|
## 0.4.5 (2013-06-21)
|
||||||
|
+ Builder: 'docker build git://URL' fetches and builds a remote git repository
|
||||||
|
* Runtime: 'docker ps -s' optionally prints container size
|
||||||
|
* Tests: Improved and simplified
|
||||||
|
- Runtime: fix a regression introduced in 0.4.3 which caused the logs command to fail.
|
||||||
|
- Builder: fix a regression when using ADD with single regular file.
|
||||||
|
|
||||||
|
## 0.4.4 (2013-06-19)
|
||||||
|
- Builder: fix a regression introduced in 0.4.3 which caused builds to fail on new clients.
|
||||||
|
|
||||||
|
## 0.4.3 (2013-06-19)
|
||||||
|
+ Builder: ADD of a local file will detect tar archives and unpack them
|
||||||
|
* Runtime: Remove bsdtar dependency
|
||||||
|
* Runtime: Add unix socket and multiple -H support
|
||||||
|
* Runtime: Prevent rm of running containers
|
||||||
|
* Runtime: Use go1.1 cookiejar
|
||||||
|
* Builder: ADD improvements: use tar for copy + automatically unpack local archives
|
||||||
|
* Builder: ADD uses tar/untar for copies instead of calling 'cp -ar'
|
||||||
|
* Builder: nicer output for 'docker build'
|
||||||
|
* Builder: fixed the behavior of ADD to be (mostly) reverse-compatible, predictable and well-documented.
|
||||||
|
* Client: HumanReadable ProgressBar sizes in pull
|
||||||
|
* Client: Fix docker version's git commit output
|
||||||
|
* API: Send all tags on History API call
|
||||||
|
* API: Add tag lookup to history command. Fixes #882
|
||||||
|
- Runtime: Fix issue detaching from running TTY container
|
||||||
|
- Runtime: Forbid parralel push/pull for a single image/repo. Fixes #311
|
||||||
|
- Runtime: Fix race condition within Run command when attaching.
|
||||||
|
- Builder: fix a bug which caused builds to fail if ADD was the first command
|
||||||
|
- Documentation: fix missing command in irc bouncer example
|
||||||
|
|
||||||
## 0.4.2 (2013-06-17)
|
## 0.4.2 (2013-06-17)
|
||||||
- Packaging: Bumped version to work around an Ubuntu bug
|
- Packaging: Bumped version to work around an Ubuntu bug
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# This file describes the standard way to build Docker, using docker
|
||||||
|
docker-version 0.4.2
|
||||||
|
from ubuntu:12.04
|
||||||
|
maintainer Solomon Hykes <solomon@dotcloud.com>
|
||||||
|
# Build dependencies
|
||||||
|
run apt-get install -y -q curl
|
||||||
|
run apt-get install -y -q git
|
||||||
|
# Install Go
|
||||||
|
run curl -s https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz | tar -v -C /usr/local -xz
|
||||||
|
env PATH /usr/local/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
|
env GOPATH /go
|
||||||
|
env CGO_ENABLED 0
|
||||||
|
run cd /tmp && echo 'package main' > t.go && go test -a -i -v
|
||||||
|
# Download dependencies
|
||||||
|
run PKG=github.com/kr/pty REV=27435c699; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
|
||||||
|
run PKG=github.com/gorilla/context/ REV=708054d61e5; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
|
||||||
|
run PKG=github.com/gorilla/mux/ REV=9b36453141c; git clone http://$PKG /go/src/$PKG && cd /go/src/$PKG && git checkout -f $REV
|
||||||
|
# Run dependencies
|
||||||
|
run apt-get install -y iptables
|
||||||
|
# lxc requires updating ubuntu sources
|
||||||
|
run echo 'deb http://archive.ubuntu.com/ubuntu precise main universe' > /etc/apt/sources.list
|
||||||
|
run apt-get update
|
||||||
|
run apt-get install -y lxc
|
||||||
|
run apt-get install -y aufs-tools
|
||||||
|
# Upload docker source
|
||||||
|
add . /go/src/github.com/dotcloud/docker
|
||||||
|
# Build the binary
|
||||||
|
run cd /go/src/github.com/dotcloud/docker/docker && go install -ldflags "-X main.GITCOMMIT '??' -d -w"
|
||||||
|
env PATH /usr/local/go/bin:/go/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
|
||||||
|
cmd ["docker"]
|
||||||
@@ -16,7 +16,6 @@ to put them - so we put them here :)
|
|||||||
* Unify build commands and regular commands
|
* Unify build commands and regular commands
|
||||||
* Move source code into src/ subdir for clarity
|
* Move source code into src/ subdir for clarity
|
||||||
* Clean up the Makefile, it's a mess
|
* Clean up the Makefile, it's a mess
|
||||||
* docker buidl: show short IDs
|
|
||||||
* docker build: on non-existent local path for ADD, don't show full absolute path on the host
|
* docker build: on non-existent local path for ADD, don't show full absolute path on the host
|
||||||
* mount into /dockerinit rather than /sbin/init
|
* mount into /dockerinit rather than /sbin/init
|
||||||
* docker tag foo REPO:TAG
|
* docker tag foo REPO:TAG
|
||||||
@@ -34,3 +33,4 @@ to put them - so we put them here :)
|
|||||||
* Caching after an ADD
|
* Caching after an ADD
|
||||||
* entry point config
|
* entry point config
|
||||||
* bring back git revision info, looks like it was lost
|
* bring back git revision info, looks like it was lost
|
||||||
|
* Clean up the ProgressReader api, it's a PITA to use
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ DOCKER_PACKAGE := github.com/dotcloud/docker
|
|||||||
RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1)
|
RELEASE_VERSION := $(shell git tag | grep -E "v[0-9\.]+$$" | sort -nr | head -n 1)
|
||||||
SRCRELEASE := docker-$(RELEASE_VERSION)
|
SRCRELEASE := docker-$(RELEASE_VERSION)
|
||||||
BINRELEASE := docker-$(RELEASE_VERSION).tgz
|
BINRELEASE := docker-$(RELEASE_VERSION).tgz
|
||||||
|
BUILD_SRC := build_src
|
||||||
|
BUILD_PATH := ${BUILD_SRC}/src/${DOCKER_PACKAGE}
|
||||||
|
|
||||||
GIT_ROOT := $(shell git rev-parse --show-toplevel)
|
GIT_ROOT := $(shell git rev-parse --show-toplevel)
|
||||||
BUILD_DIR := $(CURDIR)/.gopath
|
BUILD_DIR := $(CURDIR)/.gopath
|
||||||
@@ -9,7 +11,7 @@ BUILD_DIR := $(CURDIR)/.gopath
|
|||||||
GOPATH ?= $(BUILD_DIR)
|
GOPATH ?= $(BUILD_DIR)
|
||||||
export GOPATH
|
export GOPATH
|
||||||
|
|
||||||
GO_OPTIONS ?=
|
GO_OPTIONS ?= -a -ldflags='-w -d'
|
||||||
ifeq ($(VERBOSE), 1)
|
ifeq ($(VERBOSE), 1)
|
||||||
GO_OPTIONS += -v
|
GO_OPTIONS += -v
|
||||||
endif
|
endif
|
||||||
@@ -17,7 +19,7 @@ endif
|
|||||||
GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
GIT_COMMIT = $(shell git rev-parse --short HEAD)
|
||||||
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES")
|
GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES")
|
||||||
|
|
||||||
BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS)"
|
BUILD_OPTIONS = -a -ldflags "-X main.GITCOMMIT $(GIT_COMMIT)$(GIT_STATUS) -d -w"
|
||||||
|
|
||||||
SRC_DIR := $(GOPATH)/src
|
SRC_DIR := $(GOPATH)/src
|
||||||
|
|
||||||
@@ -33,7 +35,7 @@ all: $(DOCKER_BIN)
|
|||||||
|
|
||||||
$(DOCKER_BIN): $(DOCKER_DIR)
|
$(DOCKER_BIN): $(DOCKER_DIR)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@(cd $(DOCKER_MAIN); go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@)
|
@(cd $(DOCKER_MAIN); CGO_ENABLED=0 go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@)
|
||||||
@echo $(DOCKER_BIN_RELATIVE) is created.
|
@echo $(DOCKER_BIN_RELATIVE) is created.
|
||||||
|
|
||||||
$(DOCKER_DIR):
|
$(DOCKER_DIR):
|
||||||
@@ -47,6 +49,7 @@ whichrelease:
|
|||||||
release: $(BINRELEASE)
|
release: $(BINRELEASE)
|
||||||
s3cmd -P put $(BINRELEASE) s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-$(RELEASE_VERSION).tgz
|
s3cmd -P put $(BINRELEASE) s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-$(RELEASE_VERSION).tgz
|
||||||
s3cmd -P put docker-latest.tgz s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-latest.tgz
|
s3cmd -P put docker-latest.tgz s3://get.docker.io/builds/`uname -s`/`uname -m`/docker-latest.tgz
|
||||||
|
s3cmd -P put $(SRCRELEASE)/bin/docker s3://get.docker.io/builds/`uname -s`/`uname -m`/docker
|
||||||
|
|
||||||
srcrelease: $(SRCRELEASE)
|
srcrelease: $(SRCRELEASE)
|
||||||
deps: $(DOCKER_DIR)
|
deps: $(DOCKER_DIR)
|
||||||
@@ -71,8 +74,16 @@ else ifneq ($(DOCKER_DIR), $(realpath $(DOCKER_DIR)))
|
|||||||
@rm -f $(DOCKER_DIR)
|
@rm -f $(DOCKER_DIR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
test: all
|
test:
|
||||||
@(cd $(DOCKER_DIR); sudo -E go test $(GO_OPTIONS))
|
# Copy docker source and dependencies for testing
|
||||||
|
rm -rf ${BUILD_SRC}; mkdir -p ${BUILD_PATH}
|
||||||
|
tar --exclude=${BUILD_SRC} -cz . | tar -xz -C ${BUILD_PATH}
|
||||||
|
GOPATH=${CURDIR}/${BUILD_SRC} go get -d
|
||||||
|
# Do the test
|
||||||
|
sudo -E GOPATH=${CURDIR}/${BUILD_SRC} CGO_ENABLED=0 go test ${GO_OPTIONS}
|
||||||
|
|
||||||
|
testall: all
|
||||||
|
@(cd $(DOCKER_DIR); CGO_ENABLED=0 sudo -E go test ./... $(GO_OPTIONS))
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
@gofmt -s -l -w .
|
@gofmt -s -l -w .
|
||||||
|
|||||||
@@ -1,80 +1,129 @@
|
|||||||
Docker: the Linux container engine
|
Docker: the Linux container engine
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
Docker is an open-source engine which automates the deployment of applications as highly portable, self-sufficient containers.
|
Docker is an open-source engine which automates the deployment of
|
||||||
|
applications as highly portable, self-sufficient containers.
|
||||||
|
|
||||||
Docker containers are both *hardware-agnostic* and *platform-agnostic*. This means that they can run anywhere, from your
|
Docker containers are both *hardware-agnostic* and
|
||||||
laptop to the largest EC2 compute instance and everything in between - and they don't require that you use a particular
|
*platform-agnostic*. This means that they can run anywhere, from your
|
||||||
language, framework or packaging system. That makes them great building blocks for deploying and scaling web apps, databases
|
laptop to the largest EC2 compute instance and everything in between -
|
||||||
and backend services without depending on a particular stack or provider.
|
and they don't require that you use a particular language, framework
|
||||||
|
or packaging system. That makes them great building blocks for
|
||||||
|
deploying and scaling web apps, databases and backend services without
|
||||||
|
depending on a particular stack or provider.
|
||||||
|
|
||||||
Docker is an open-source implementation of the deployment engine which powers [dotCloud](http://dotcloud.com), a popular Platform-as-a-Service.
|
Docker is an open-source implementation of the deployment engine which
|
||||||
It benefits directly from the experience accumulated over several years of large-scale operation and support of hundreds of thousands
|
powers [dotCloud](http://dotcloud.com), a popular
|
||||||
of applications and databases.
|
Platform-as-a-Service. It benefits directly from the experience
|
||||||
|
accumulated over several years of large-scale operation and support of
|
||||||
|
hundreds of thousands of applications and databases.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Better than VMs
|
## Better than VMs
|
||||||
|
|
||||||
A common method for distributing applications and sandbox their execution is to use virtual machines, or VMs. Typical VM formats
|
A common method for distributing applications and sandbox their
|
||||||
are VMWare's vmdk, Oracle Virtualbox's vdi, and Amazon EC2's ami. In theory these formats should allow every developer to
|
execution is to use virtual machines, or VMs. Typical VM formats are
|
||||||
automatically package their application into a "machine" for easy distribution and deployment. In practice, that almost never
|
VMWare's vmdk, Oracle Virtualbox's vdi, and Amazon EC2's ami. In
|
||||||
happens, for a few reasons:
|
theory these formats should allow every developer to automatically
|
||||||
|
package their application into a "machine" for easy distribution and
|
||||||
|
deployment. In practice, that almost never happens, for a few reasons:
|
||||||
|
|
||||||
* *Size*: VMs are very large which makes them impractical to store and transfer.
|
* *Size*: VMs are very large which makes them impractical to store
|
||||||
* *Performance*: running VMs consumes significant CPU and memory, which makes them impractical in many scenarios, for example local development of multi-tier applications, and
|
and transfer.
|
||||||
large-scale deployment of cpu and memory-intensive applications on large numbers of machines.
|
* *Performance*: running VMs consumes significant CPU and memory,
|
||||||
* *Portability*: competing VM environments don't play well with each other. Although conversion tools do exist, they are limited and add even more overhead.
|
which makes them impractical in many scenarios, for example local
|
||||||
* *Hardware-centric*: VMs were designed with machine operators in mind, not software developers. As a result, they offer very limited tooling for what developers need most:
|
development of multi-tier applications, and large-scale deployment
|
||||||
building, testing and running their software. For example, VMs offer no facilities for application versioning, monitoring, configuration, logging or service discovery.
|
of cpu and memory-intensive applications on large numbers of
|
||||||
|
machines.
|
||||||
|
* *Portability*: competing VM environments don't play well with each
|
||||||
|
other. Although conversion tools do exist, they are limited and
|
||||||
|
add even more overhead.
|
||||||
|
* *Hardware-centric*: VMs were designed with machine operators in
|
||||||
|
mind, not software developers. As a result, they offer very
|
||||||
|
limited tooling for what developers need most: building, testing
|
||||||
|
and running their software. For example, VMs offer no facilities
|
||||||
|
for application versioning, monitoring, configuration, logging or
|
||||||
|
service discovery.
|
||||||
|
|
||||||
By contrast, Docker relies on a different sandboxing method known as *containerization*. Unlike traditional virtualization,
|
By contrast, Docker relies on a different sandboxing method known as
|
||||||
containerization takes place at the kernel level. Most modern operating system kernels now support the primitives necessary
|
*containerization*. Unlike traditional virtualization,
|
||||||
for containerization, including Linux with [openvz](http://openvz.org), [vserver](http://linux-vserver.org) and more recently [lxc](http://lxc.sourceforge.net),
|
containerization takes place at the kernel level. Most modern
|
||||||
Solaris with [zones](http://docs.oracle.com/cd/E26502_01/html/E29024/preface-1.html#scrolltoc) and FreeBSD with [Jails](http://www.freebsd.org/doc/handbook/jails.html).
|
operating system kernels now support the primitives necessary for
|
||||||
|
containerization, including Linux with [openvz](http://openvz.org),
|
||||||
|
[vserver](http://linux-vserver.org) and more recently
|
||||||
|
[lxc](http://lxc.sourceforge.net), Solaris with
|
||||||
|
[zones](http://docs.oracle.com/cd/E26502_01/html/E29024/preface-1.html#scrolltoc)
|
||||||
|
and FreeBSD with
|
||||||
|
[Jails](http://www.freebsd.org/doc/handbook/jails.html).
|
||||||
|
|
||||||
Docker builds on top of these low-level primitives to offer developers a portable format and runtime environment that solves
|
Docker builds on top of these low-level primitives to offer developers
|
||||||
all 4 problems. Docker containers are small (and their transfer can be optimized with layers), they have basically zero memory and cpu overhead,
|
a portable format and runtime environment that solves all 4
|
||||||
they are completely portable and are designed from the ground up with an application-centric design.
|
problems. Docker containers are small (and their transfer can be
|
||||||
|
optimized with layers), they have basically zero memory and cpu
|
||||||
|
overhead, they are completely portable and are designed from the
|
||||||
|
ground up with an application-centric design.
|
||||||
|
|
||||||
The best part: because docker operates at the OS level, it can still be run inside a VM!
|
The best part: because ``docker`` operates at the OS level, it can
|
||||||
|
still be run inside a VM!
|
||||||
|
|
||||||
## Plays well with others
|
## Plays well with others
|
||||||
|
|
||||||
Docker does not require that you buy into a particular programming language, framework, packaging system or configuration language.
|
Docker does not require that you buy into a particular programming
|
||||||
|
language, framework, packaging system or configuration language.
|
||||||
|
|
||||||
Is your application a unix process? Does it use files, tcp connections, environment variables, standard unix streams and command-line
|
Is your application a Unix process? Does it use files, tcp
|
||||||
arguments as inputs and outputs? Then docker can run it.
|
connections, environment variables, standard Unix streams and
|
||||||
|
command-line arguments as inputs and outputs? Then ``docker`` can run
|
||||||
|
it.
|
||||||
|
|
||||||
Can your application's build be expressed as a sequence of such commands? Then docker can build it.
|
Can your application's build be expressed as a sequence of such
|
||||||
|
commands? Then ``docker`` can build it.
|
||||||
|
|
||||||
|
|
||||||
## Escape dependency hell
|
## Escape dependency hell
|
||||||
|
|
||||||
A common problem for developers is the difficulty of managing all their application's dependencies in a simple and automated way.
|
A common problem for developers is the difficulty of managing all
|
||||||
|
their application's dependencies in a simple and automated way.
|
||||||
|
|
||||||
This is usually difficult for several reasons:
|
This is usually difficult for several reasons:
|
||||||
|
|
||||||
* *Cross-platform dependencies*. Modern applications often depend on a combination of system libraries and binaries, language-specific packages, framework-specific modules,
|
* *Cross-platform dependencies*. Modern applications often depend on
|
||||||
internal components developed for another project, etc. These dependencies live in different "worlds" and require different tools - these tools typically don't work
|
a combination of system libraries and binaries, language-specific
|
||||||
well with each other, requiring awkward custom integrations.
|
packages, framework-specific modules, internal components
|
||||||
|
developed for another project, etc. These dependencies live in
|
||||||
|
different "worlds" and require different tools - these tools
|
||||||
|
typically don't work well with each other, requiring awkward
|
||||||
|
custom integrations.
|
||||||
|
|
||||||
* Conflicting dependencies. Different applications may depend on different versions of the same dependency. Packaging tools handle these situations with various degrees of ease -
|
* Conflicting dependencies. Different applications may depend on
|
||||||
but they all handle them in different and incompatible ways, which again forces the developer to do extra work.
|
different versions of the same dependency. Packaging tools handle
|
||||||
|
these situations with various degrees of ease - but they all
|
||||||
|
handle them in different and incompatible ways, which again forces
|
||||||
|
the developer to do extra work.
|
||||||
|
|
||||||
* Custom dependencies. A developer may need to prepare a custom version of his application's dependency. Some packaging systems can handle custom versions of a dependency,
|
* Custom dependencies. A developer may need to prepare a custom
|
||||||
others can't - and all of them handle it differently.
|
version of their application's dependency. Some packaging systems
|
||||||
|
can handle custom versions of a dependency, others can't - and all
|
||||||
|
of them handle it differently.
|
||||||
|
|
||||||
|
|
||||||
Docker solves dependency hell by giving the developer a simple way to express *all* his application's dependencies in one place,
|
Docker solves dependency hell by giving the developer a simple way to
|
||||||
and streamline the process of assembling them. If this makes you think of [XKCD 927](http://xkcd.com/927/), don't worry. Docker doesn't
|
express *all* their application's dependencies in one place, and
|
||||||
*replace* your favorite packaging systems. It simply orchestrates their use in a simple and repeatable way. How does it do that? With layers.
|
streamline the process of assembling them. If this makes you think of
|
||||||
|
[XKCD 927](http://xkcd.com/927/), don't worry. Docker doesn't
|
||||||
|
*replace* your favorite packaging systems. It simply orchestrates
|
||||||
|
their use in a simple and repeatable way. How does it do that? With
|
||||||
|
layers.
|
||||||
|
|
||||||
Docker defines a build as running a sequence of unix commands, one after the other, in the same container. Build commands modify the contents of the container
|
Docker defines a build as running a sequence of Unix commands, one
|
||||||
(usually by installing new files on the filesystem), the next command modifies it some more, etc. Since each build command inherits the result of the previous
|
after the other, in the same container. Build commands modify the
|
||||||
commands, the *order* in which the commands are executed expresses *dependencies*.
|
contents of the container (usually by installing new files on the
|
||||||
|
filesystem), the next command modifies it some more, etc. Since each
|
||||||
|
build command inherits the result of the previous commands, the
|
||||||
|
*order* in which the commands are executed expresses *dependencies*.
|
||||||
|
|
||||||
Here's a typical docker build process:
|
Here's a typical Docker build process:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
from ubuntu:12.10
|
from ubuntu:12.10
|
||||||
@@ -87,7 +136,8 @@ run curl -L https://github.com/shykes/helloflask/archive/master.tar.gz | tar -xz
|
|||||||
run cd helloflask-master && pip install -r requirements.txt
|
run cd helloflask-master && pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that Docker doesn't care *how* dependencies are built - as long as they can be built by running a unix command in a container.
|
Note that Docker doesn't care *how* dependencies are built - as long
|
||||||
|
as they can be built by running a Unix command in a container.
|
||||||
|
|
||||||
|
|
||||||
Install instructions
|
Install instructions
|
||||||
@@ -97,33 +147,34 @@ Quick install on Ubuntu 12.04 and 12.10
|
|||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl get.docker.io | sh -x
|
curl get.docker.io | sudo sh -x
|
||||||
```
|
```
|
||||||
|
|
||||||
Binary installs
|
Binary installs
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Docker supports the following binary installation methods.
|
Docker supports the following binary installation methods. Note that
|
||||||
Note that some methods are community contributions and not yet officially supported.
|
some methods are community contributions and not yet officially
|
||||||
|
supported.
|
||||||
|
|
||||||
* [Ubuntu 12.04 and 12.10 (officially supported)](http://docs.docker.io/en/latest/installation/ubuntulinux/)
|
* [Ubuntu 12.04 and 12.10 (officially supported)](http://docs.docker.io/en/latest/installation/ubuntulinux/)
|
||||||
* [Arch Linux](http://docs.docker.io/en/latest/installation/archlinux/)
|
* [Arch Linux](http://docs.docker.io/en/latest/installation/archlinux/)
|
||||||
* [MacOS X (with Vagrant)](http://docs.docker.io/en/latest/installation/macos/)
|
* [Mac OS X (with Vagrant)](http://docs.docker.io/en/latest/installation/vagrant/)
|
||||||
* [Windows (with Vagrant)](http://docs.docker.io/en/latest/installation/windows/)
|
* [Windows (with Vagrant)](http://docs.docker.io/en/latest/installation/windows/)
|
||||||
* [Amazon EC2 (with Vagrant)](http://docs.docker.io/en/latest/installation/amazon/)
|
* [Amazon EC2 (with Vagrant)](http://docs.docker.io/en/latest/installation/amazon/)
|
||||||
|
|
||||||
Installing from source
|
Installing from source
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
1. Make sure you have a [Go language](http://golang.org/doc/install) compiler and [git](http://git-scm.com) installed.
|
1. Make sure you have a [Go language](http://golang.org/doc/install)
|
||||||
|
compiler >= 1.1 and [git](http://git-scm.com) installed.
|
||||||
2. Checkout the source code
|
2. Checkout the source code
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone http://github.com/dotcloud/docker
|
git clone http://github.com/dotcloud/docker
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Build the docker binary
|
3. Build the ``docker`` binary
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd docker
|
cd docker
|
||||||
@@ -134,17 +185,20 @@ Installing from source
|
|||||||
Usage examples
|
Usage examples
|
||||||
==============
|
==============
|
||||||
|
|
||||||
First run the docker daemon
|
First run the ``docker`` daemon
|
||||||
---------------------------
|
-------------------------------
|
||||||
|
|
||||||
All the examples assume your machine is running the docker daemon. To run the docker daemon in the background, simply type:
|
All the examples assume your machine is running the ``docker``
|
||||||
|
daemon. To run the ``docker`` daemon in the background, simply type:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# On a production system you want this running in an init script
|
# On a production system you want this running in an init script
|
||||||
sudo docker -d &
|
sudo docker -d &
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can run docker in client mode: all commands will be forwarded to the docker daemon, so the client can run from any account.
|
Now you can run ``docker`` in client mode: all commands will be
|
||||||
|
forwarded to the ``docker`` daemon, so the client can run from any
|
||||||
|
account.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Now you can run docker commands from any account.
|
# Now you can run docker commands from any account.
|
||||||
@@ -152,7 +206,7 @@ docker help
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Throwaway shell in a base ubuntu image
|
Throwaway shell in a base Ubuntu image
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -181,7 +235,7 @@ Running an irc bouncer
|
|||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
BOUNCER_ID=$(docker run -d -p 6667 -u irc shykes/znc $USER $PASSWORD)
|
BOUNCER_ID=$(docker run -d -p 6667 -u irc shykes/znc zncrun $USER $PASSWORD)
|
||||||
echo "Configure your irc client to connect to port $(docker port $BOUNCER_ID 6667) of this machine"
|
echo "Configure your irc client to connect to port $(docker port $BOUNCER_ID 6667) of this machine"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -202,7 +256,8 @@ docker commit -m "Installed curl" $CONTAINER $USER/betterbase
|
|||||||
docker push $USER/betterbase
|
docker push $USER/betterbase
|
||||||
```
|
```
|
||||||
|
|
||||||
A list of publicly available images is [available here](https://github.com/dotcloud/docker/wiki/Public-docker-images).
|
A list of publicly available images is [available
|
||||||
|
here](https://github.com/dotcloud/docker/wiki/Public-docker-images).
|
||||||
|
|
||||||
Expose a service on a TCP port
|
Expose a service on a TCP port
|
||||||
------------------------------
|
------------------------------
|
||||||
@@ -216,7 +271,8 @@ PORT=$(docker port $JOB 4444)
|
|||||||
|
|
||||||
# Connect to the public port via the host's public address
|
# Connect to the public port via the host's public address
|
||||||
# Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
|
# Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
|
||||||
IP=$(ifconfig eth0 | perl -n -e 'if (m/inet addr:([\d\.]+)/g) { print $1 }')
|
# Replace *eth0* according to your local interface name.
|
||||||
|
IP=$(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }')
|
||||||
echo hello world | nc $IP $PORT
|
echo hello world | nc $IP $PORT
|
||||||
|
|
||||||
# Verify that the network connection worked
|
# Verify that the network connection worked
|
||||||
@@ -228,32 +284,40 @@ Under the hood
|
|||||||
|
|
||||||
Under the hood, Docker is built on the following components:
|
Under the hood, Docker is built on the following components:
|
||||||
|
|
||||||
|
* The
|
||||||
* The [cgroup](http://blog.dotcloud.com/kernel-secrets-from-the-paas-garage-part-24-c) and [namespacing](http://blog.dotcloud.com/under-the-hood-linux-kernels-on-dotcloud-part) capabilities of the Linux kernel;
|
[cgroup](http://blog.dotcloud.com/kernel-secrets-from-the-paas-garage-part-24-c)
|
||||||
|
and
|
||||||
* [AUFS](http://aufs.sourceforge.net/aufs.html), a powerful union filesystem with copy-on-write capabilities;
|
[namespacing](http://blog.dotcloud.com/under-the-hood-linux-kernels-on-dotcloud-part)
|
||||||
|
capabilities of the Linux kernel;
|
||||||
|
* [AUFS](http://aufs.sourceforge.net/aufs.html), a powerful union
|
||||||
|
filesystem with copy-on-write capabilities;
|
||||||
* The [Go](http://golang.org) programming language;
|
* The [Go](http://golang.org) programming language;
|
||||||
|
* [lxc](http://lxc.sourceforge.net/), a set of convenience scripts to
|
||||||
* [lxc](http://lxc.sourceforge.net/), a set of convenience scripts to simplify the creation of linux containers.
|
simplify the creation of Linux containers.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Contributing to Docker
|
Contributing to Docker
|
||||||
======================
|
======================
|
||||||
|
|
||||||
Want to hack on Docker? Awesome! There are instructions to get you started on the website: http://docs.docker.io/en/latest/contributing/contributing/
|
Want to hack on Docker? Awesome! There are instructions to get you
|
||||||
|
started on the website:
|
||||||
|
http://docs.docker.io/en/latest/contributing/contributing/
|
||||||
|
|
||||||
They are probably not perfect, please let us know if anything feels wrong or incomplete.
|
They are probably not perfect, please let us know if anything feels
|
||||||
|
wrong or incomplete.
|
||||||
|
|
||||||
|
|
||||||
Note
|
Note
|
||||||
----
|
----
|
||||||
|
|
||||||
We also keep the documentation in this repository. The website documentation is generated using sphinx using these sources.
|
We also keep the documentation in this repository. The website
|
||||||
Please find it under docs/sources/ and read more about it https://github.com/dotcloud/docker/tree/master/docs/README.md
|
documentation is generated using Sphinx using these sources. Please
|
||||||
|
find it under docs/sources/ and read more about it
|
||||||
|
https://github.com/dotcloud/docker/tree/master/docs/README.md
|
||||||
|
|
||||||
Please feel free to fix / update the documentation and send us pull requests. More tutorials are also welcome.
|
Please feel free to fix / update the documentation and send us pull
|
||||||
|
requests. More tutorials are also welcome.
|
||||||
|
|
||||||
|
|
||||||
Setting up a dev environment
|
Setting up a dev environment
|
||||||
@@ -262,14 +326,14 @@ Setting up a dev environment
|
|||||||
Instructions that have been verified to work on Ubuntu 12.10,
|
Instructions that have been verified to work on Ubuntu 12.10,
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get -y install lxc wget bsdtar curl golang git
|
sudo apt-get -y install lxc curl xz-utils golang git
|
||||||
|
|
||||||
export GOPATH=~/go/
|
export GOPATH=~/go/
|
||||||
export PATH=$GOPATH/bin:$PATH
|
export PATH=$GOPATH/bin:$PATH
|
||||||
|
|
||||||
mkdir -p $GOPATH/src/github.com/dotcloud
|
mkdir -p $GOPATH/src/github.com/dotcloud
|
||||||
cd $GOPATH/src/github.com/dotcloud
|
cd $GOPATH/src/github.com/dotcloud
|
||||||
git clone git@github.com:dotcloud/docker.git
|
git clone https://github.com/dotcloud/docker.git
|
||||||
cd docker
|
cd docker
|
||||||
|
|
||||||
go get -v github.com/dotcloud/docker/...
|
go get -v github.com/dotcloud/docker/...
|
||||||
@@ -288,93 +352,104 @@ Run the `go install` command (above) to recompile docker.
|
|||||||
What is a Standard Container?
|
What is a Standard Container?
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
Docker defines a unit of software delivery called a Standard Container. The goal of a Standard Container is to encapsulate a software component and all its dependencies in
|
Docker defines a unit of software delivery called a Standard
|
||||||
a format that is self-describing and portable, so that any compliant runtime can run it without extra dependencies, regardless of the underlying machine and the contents of the container.
|
Container. The goal of a Standard Container is to encapsulate a
|
||||||
|
software component and all its dependencies in a format that is
|
||||||
|
self-describing and portable, so that any compliant runtime can run it
|
||||||
|
without extra dependencies, regardless of the underlying machine and
|
||||||
|
the contents of the container.
|
||||||
|
|
||||||
The spec for Standard Containers is currently a work in progress, but it is very straightforward. It mostly defines 1) an image format, 2) a set of standard operations, and 3) an execution environment.
|
The spec for Standard Containers is currently a work in progress, but
|
||||||
|
it is very straightforward. It mostly defines 1) an image format, 2) a
|
||||||
|
set of standard operations, and 3) an execution environment.
|
||||||
|
|
||||||
A great analogy for this is the shipping container. Just like how Standard Containers are a fundamental unit of software delivery, shipping containers (http://bricks.argz.com/ins/7823-1/12) are a fundamental unit of physical delivery.
|
A great analogy for this is the shipping container. Just like how
|
||||||
|
Standard Containers are a fundamental unit of software delivery,
|
||||||
|
shipping containers are a fundamental unit of physical delivery.
|
||||||
|
|
||||||
### 1. STANDARD OPERATIONS
|
### 1. STANDARD OPERATIONS
|
||||||
|
|
||||||
Just like shipping containers, Standard Containers define a set of STANDARD OPERATIONS. Shipping containers can be lifted, stacked, locked, loaded, unloaded and labelled. Similarly, standard containers can be started, stopped, copied, snapshotted, downloaded, uploaded and tagged.
|
Just like shipping containers, Standard Containers define a set of
|
||||||
|
STANDARD OPERATIONS. Shipping containers can be lifted, stacked,
|
||||||
|
locked, loaded, unloaded and labelled. Similarly, Standard Containers
|
||||||
|
can be started, stopped, copied, snapshotted, downloaded, uploaded and
|
||||||
|
tagged.
|
||||||
|
|
||||||
|
|
||||||
### 2. CONTENT-AGNOSTIC
|
### 2. CONTENT-AGNOSTIC
|
||||||
|
|
||||||
Just like shipping containers, Standard Containers are CONTENT-AGNOSTIC: all standard operations have the same effect regardless of the contents. A shipping container will be stacked in exactly the same way whether it contains Vietnamese powder coffee or spare Maserati parts. Similarly, Standard Containers are started or uploaded in the same way whether they contain a postgres database, a php application with its dependencies and application server, or Java build artifacts.
|
Just like shipping containers, Standard Containers are
|
||||||
|
CONTENT-AGNOSTIC: all standard operations have the same effect
|
||||||
|
regardless of the contents. A shipping container will be stacked in
|
||||||
|
exactly the same way whether it contains Vietnamese powder coffee or
|
||||||
|
spare Maserati parts. Similarly, Standard Containers are started or
|
||||||
|
uploaded in the same way whether they contain a postgres database, a
|
||||||
|
php application with its dependencies and application server, or Java
|
||||||
|
build artifacts.
|
||||||
|
|
||||||
|
|
||||||
### 3. INFRASTRUCTURE-AGNOSTIC
|
### 3. INFRASTRUCTURE-AGNOSTIC
|
||||||
|
|
||||||
Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be transported to thousands of facilities around the world, and manipulated by a wide variety of equipment. A shipping container can be packed in a factory in Ukraine, transported by truck to the nearest routing center, stacked onto a train, loaded into a German boat by an Australian-built crane, stored in a warehouse at a US facility, etc. Similarly, a standard container can be bundled on my laptop, uploaded to S3, downloaded, run and snapshotted by a build server at Equinix in Virginia, uploaded to 10 staging servers in a home-made Openstack cluster, then sent to 30 production instances across 3 EC2 regions.
|
Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be
|
||||||
|
transported to thousands of facilities around the world, and
|
||||||
|
manipulated by a wide variety of equipment. A shipping container can
|
||||||
|
be packed in a factory in Ukraine, transported by truck to the nearest
|
||||||
|
routing center, stacked onto a train, loaded into a German boat by an
|
||||||
|
Australian-built crane, stored in a warehouse at a US facility,
|
||||||
|
etc. Similarly, a standard container can be bundled on my laptop,
|
||||||
|
uploaded to S3, downloaded, run and snapshotted by a build server at
|
||||||
|
Equinix in Virginia, uploaded to 10 staging servers in a home-made
|
||||||
|
Openstack cluster, then sent to 30 production instances across 3 EC2
|
||||||
|
regions.
|
||||||
|
|
||||||
|
|
||||||
### 4. DESIGNED FOR AUTOMATION
|
### 4. DESIGNED FOR AUTOMATION
|
||||||
|
|
||||||
Because they offer the same standard operations regardless of content and infrastructure, Standard Containers, just like their physical counterpart, are extremely well-suited for automation. In fact, you could say automation is their secret weapon.
|
Because they offer the same standard operations regardless of content
|
||||||
|
and infrastructure, Standard Containers, just like their physical
|
||||||
|
counterparts, are extremely well-suited for automation. In fact, you
|
||||||
|
could say automation is their secret weapon.
|
||||||
|
|
||||||
Many things that once required time-consuming and error-prone human effort can now be programmed. Before shipping containers, a bag of powder coffee was hauled, dragged, dropped, rolled and stacked by 10 different people in 10 different locations by the time it reached its destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The process was slow, inefficient and cost a fortune - and was entirely different depending on the facility and the type of goods.
|
Many things that once required time-consuming and error-prone human
|
||||||
|
effort can now be programmed. Before shipping containers, a bag of
|
||||||
|
powder coffee was hauled, dragged, dropped, rolled and stacked by 10
|
||||||
|
different people in 10 different locations by the time it reached its
|
||||||
|
destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The
|
||||||
|
process was slow, inefficient and cost a fortune - and was entirely
|
||||||
|
different depending on the facility and the type of goods.
|
||||||
|
|
||||||
Similarly, before Standard Containers, by the time a software component ran in production, it had been individually built, configured, bundled, documented, patched, vendored, templated, tweaked and instrumented by 10 different people on 10 different computers. Builds failed, libraries conflicted, mirrors crashed, post-it notes were lost, logs were misplaced, cluster updates were half-broken. The process was slow, inefficient and cost a fortune - and was entirely different depending on the language and infrastructure provider.
|
Similarly, before Standard Containers, by the time a software
|
||||||
|
component ran in production, it had been individually built,
|
||||||
|
configured, bundled, documented, patched, vendored, templated, tweaked
|
||||||
|
and instrumented by 10 different people on 10 different
|
||||||
|
computers. Builds failed, libraries conflicted, mirrors crashed,
|
||||||
|
post-it notes were lost, logs were misplaced, cluster updates were
|
||||||
|
half-broken. The process was slow, inefficient and cost a fortune -
|
||||||
|
and was entirely different depending on the language and
|
||||||
|
infrastructure provider.
|
||||||
|
|
||||||
|
|
||||||
### 5. INDUSTRIAL-GRADE DELIVERY
|
### 5. INDUSTRIAL-GRADE DELIVERY
|
||||||
|
|
||||||
There are 17 million shipping containers in existence, packed with every physical good imaginable. Every single one of them can be loaded onto the same boats, by the same cranes, in the same facilities, and sent anywhere in the World with incredible efficiency. It is embarrassing to think that a 30 ton shipment of coffee can safely travel half-way across the World in *less time* than it takes a software team to deliver its code from one datacenter to another sitting 10 miles away.
|
There are 17 million shipping containers in existence, packed with
|
||||||
|
every physical good imaginable. Every single one of them can be loaded
|
||||||
|
onto the same boats, by the same cranes, in the same facilities, and
|
||||||
|
sent anywhere in the World with incredible efficiency. It is
|
||||||
|
embarrassing to think that a 30 ton shipment of coffee can safely
|
||||||
|
travel half-way across the World in *less time* than it takes a
|
||||||
|
software team to deliver its code from one datacenter to another
|
||||||
|
sitting 10 miles away.
|
||||||
|
|
||||||
With Standard Containers we can put an end to that embarrassment, by making INDUSTRIAL-GRADE DELIVERY of software a reality.
|
With Standard Containers we can put an end to that embarrassment, by
|
||||||
|
making INDUSTRIAL-GRADE DELIVERY of software a reality.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Standard Container Specification
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
(TODO)
|
|
||||||
|
|
||||||
### Image format
|
|
||||||
|
|
||||||
|
|
||||||
### Standard operations
|
|
||||||
|
|
||||||
* Copy
|
|
||||||
* Run
|
|
||||||
* Stop
|
|
||||||
* Wait
|
|
||||||
* Commit
|
|
||||||
* Attach standard streams
|
|
||||||
* List filesystem changes
|
|
||||||
* ...
|
|
||||||
|
|
||||||
### Execution environment
|
|
||||||
|
|
||||||
#### Root filesystem
|
|
||||||
|
|
||||||
#### Environment variables
|
|
||||||
|
|
||||||
#### Process arguments
|
|
||||||
|
|
||||||
#### Networking
|
|
||||||
|
|
||||||
#### Process namespacing
|
|
||||||
|
|
||||||
#### Resource limits
|
|
||||||
|
|
||||||
#### Process monitoring
|
|
||||||
|
|
||||||
#### Logging
|
|
||||||
|
|
||||||
#### Signals
|
|
||||||
|
|
||||||
#### Pseudo-terminal allocation
|
|
||||||
|
|
||||||
#### Security
|
|
||||||
|
|
||||||
### Legal
|
### Legal
|
||||||
|
|
||||||
Transfers of Docker shall be in accordance with applicable export controls of any country and all other applicable
|
Transfers of Docker shall be in accordance with applicable export
|
||||||
legal requirements. Docker shall not be distributed or downloaded to or in Cuba, Iran, North Korea, Sudan or Syria
|
controls of any country and all other applicable legal requirements.
|
||||||
and shall not be distributed or downloaded to any person on the Denied Persons List administered by the U.S.
|
Docker shall not be distributed or downloaded to or in Cuba, Iran,
|
||||||
|
North Korea, Sudan or Syria and shall not be distributed or downloaded
|
||||||
|
to any person on the Denied Persons List administered by the U.S.
|
||||||
Department of Commerce.
|
Department of Commerce.
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
|
BOX_NAME = ENV['BOX_NAME'] || "ubuntu"
|
||||||
BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
|
BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64.box"
|
||||||
|
VF_BOX_URI = ENV['BOX_URI'] || "http://files.vagrantup.com/precise64_vmware_fusion.box"
|
||||||
AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
|
AWS_REGION = ENV['AWS_REGION'] || "us-east-1"
|
||||||
AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9"
|
AWS_AMI = ENV['AWS_AMI'] || "ami-d0f89fb9"
|
||||||
FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']
|
FORWARD_DOCKER_PORTS = ENV['FORWARD_DOCKER_PORTS']
|
||||||
@@ -19,6 +20,8 @@ Vagrant::Config.run do |config|
|
|||||||
pkg_cmd = "apt-get update -qq; apt-get install -q -y python-software-properties; " \
|
pkg_cmd = "apt-get update -qq; apt-get install -q -y python-software-properties; " \
|
||||||
"add-apt-repository -y ppa:dotcloud/lxc-docker; apt-get update -qq; " \
|
"add-apt-repository -y ppa:dotcloud/lxc-docker; apt-get update -qq; " \
|
||||||
"apt-get install -q -y lxc-docker; "
|
"apt-get install -q -y lxc-docker; "
|
||||||
|
# Listen on all interfaces so that the daemon is accessible from the host
|
||||||
|
pkg_cmd << "sed -i -E 's| /usr/bin/docker -d| /usr/bin/docker -d -H 0.0.0.0|' /etc/init/docker.conf;"
|
||||||
# Add X.org Ubuntu backported 3.8 kernel
|
# Add X.org Ubuntu backported 3.8 kernel
|
||||||
pkg_cmd << "add-apt-repository -y ppa:ubuntu-x-swat/r-lts-backport; " \
|
pkg_cmd << "add-apt-repository -y ppa:ubuntu-x-swat/r-lts-backport; " \
|
||||||
"apt-get update -qq; apt-get install -q -y linux-image-3.8.0-19-generic; "
|
"apt-get update -qq; apt-get install -q -y linux-image-3.8.0-19-generic; "
|
||||||
@@ -67,6 +70,13 @@ Vagrant::VERSION >= "1.1.0" and Vagrant.configure("2") do |config|
|
|||||||
rs.image = /Ubuntu/
|
rs.image = /Ubuntu/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.vm.provider :vmware_fusion do |f, override|
|
||||||
|
override.vm.box = BOX_NAME
|
||||||
|
override.vm.box_url = VF_BOX_URI
|
||||||
|
override.vm.synced_folder ".", "/vagrant", disabled: true
|
||||||
|
f.vmx["displayName"] = "docker"
|
||||||
|
end
|
||||||
|
|
||||||
config.vm.provider :virtualbox do |vb|
|
config.vm.provider :virtualbox do |vb|
|
||||||
config.vm.box = BOX_NAME
|
config.vm.box = BOX_NAME
|
||||||
config.vm.box_url = BOX_URI
|
config.vm.box_url = BOX_URI
|
||||||
|
|||||||
@@ -7,13 +7,20 @@ import (
|
|||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APIVERSION = 1.2
|
const APIVERSION = 1.4
|
||||||
|
const DEFAULTHTTPHOST = "127.0.0.1"
|
||||||
|
const DEFAULTHTTPPORT = 4243
|
||||||
|
const DEFAULTUNIXSOCKET = "/var/run/docker.sock"
|
||||||
|
|
||||||
func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
|
func hijackServer(w http.ResponseWriter) (io.ReadCloser, io.Writer, error) {
|
||||||
conn, _, err := w.(http.Hijacker).Hijack()
|
conn, _, err := w.(http.Hijacker).Hijack()
|
||||||
@@ -41,17 +48,22 @@ func parseMultipartForm(r *http.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func httpError(w http.ResponseWriter, err error) {
|
func httpError(w http.ResponseWriter, err error) {
|
||||||
|
statusCode := http.StatusInternalServerError
|
||||||
if strings.HasPrefix(err.Error(), "No such") {
|
if strings.HasPrefix(err.Error(), "No such") {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
statusCode = http.StatusNotFound
|
||||||
} else if strings.HasPrefix(err.Error(), "Bad parameter") {
|
} else if strings.HasPrefix(err.Error(), "Bad parameter") {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
statusCode = http.StatusBadRequest
|
||||||
} else if strings.HasPrefix(err.Error(), "Conflict") {
|
} else if strings.HasPrefix(err.Error(), "Conflict") {
|
||||||
http.Error(w, err.Error(), http.StatusConflict)
|
statusCode = http.StatusConflict
|
||||||
} else if strings.HasPrefix(err.Error(), "Impossible") {
|
} else if strings.HasPrefix(err.Error(), "Impossible") {
|
||||||
http.Error(w, err.Error(), http.StatusNotAcceptable)
|
statusCode = http.StatusNotAcceptable
|
||||||
} else {
|
} else if strings.HasPrefix(err.Error(), "Wrong login/password") {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
statusCode = http.StatusUnauthorized
|
||||||
|
} else if strings.Contains(err.Error(), "hasn't been activated") {
|
||||||
|
statusCode = http.StatusForbidden
|
||||||
}
|
}
|
||||||
|
utils.Debugf("[error %d] %s", statusCode, err)
|
||||||
|
http.Error(w, err.Error(), statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeJSON(w http.ResponseWriter, b []byte) {
|
func writeJSON(w http.ResponseWriter, b []byte) {
|
||||||
@@ -59,35 +71,15 @@ func writeJSON(w http.ResponseWriter, b []byte) {
|
|||||||
w.Write(b)
|
w.Write(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Use stvconv.ParseBool() instead?
|
|
||||||
func getBoolParam(value string) (bool, error) {
|
func getBoolParam(value string) (bool, error) {
|
||||||
if value == "1" || strings.ToLower(value) == "true" {
|
if value == "" {
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
if value == "" || value == "0" || strings.ToLower(value) == "false" {
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, fmt.Errorf("Bad parameter")
|
ret, err := strconv.ParseBool(value)
|
||||||
}
|
|
||||||
|
|
||||||
func getAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
|
||||||
if version > 1.1 {
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
authConfig, err := auth.LoadConfig(srv.runtime.root)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != auth.ErrConfigFileMissing {
|
return false, fmt.Errorf("Bad parameter")
|
||||||
return err
|
|
||||||
}
|
|
||||||
authConfig = &auth.AuthConfig{}
|
|
||||||
}
|
}
|
||||||
b, err := json.Marshal(&auth.AuthConfig{Username: authConfig.Username, Email: authConfig.Email})
|
return ret, nil
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
writeJSON(w, b)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
@@ -96,28 +88,9 @@ func postAuth(srv *Server, version float64, w http.ResponseWriter, r *http.Reque
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
status := ""
|
status, err := auth.Login(authConfig)
|
||||||
if version > 1.1 {
|
if err != nil {
|
||||||
status, err = auth.Login(authConfig, false)
|
return err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
localAuthConfig, err := auth.LoadConfig(srv.runtime.root)
|
|
||||||
if err != nil {
|
|
||||||
if err != auth.ErrConfigFileMissing {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if authConfig.Username == localAuthConfig.Username {
|
|
||||||
authConfig.Password = localAuthConfig.Password
|
|
||||||
}
|
|
||||||
|
|
||||||
newAuthConfig := auth.NewAuthConfig(authConfig.Username, authConfig.Password, authConfig.Email, srv.runtime.root)
|
|
||||||
status, err = auth.Login(newAuthConfig, true)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if status != "" {
|
if status != "" {
|
||||||
b, err := json.Marshal(&APIAuth{Status: status})
|
b, err := json.Marshal(&APIAuth{Status: status})
|
||||||
@@ -160,7 +133,7 @@ func getContainersExport(srv *Server, version float64, w http.ResponseWriter, r
|
|||||||
name := vars["name"]
|
name := vars["name"]
|
||||||
|
|
||||||
if err := srv.ContainerExport(name, w); err != nil {
|
if err := srv.ContainerExport(name, w); err != nil {
|
||||||
utils.Debugf("%s", err.Error())
|
utils.Debugf("%s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -206,6 +179,64 @@ func getInfo(srv *Server, version float64, w http.ResponseWriter, r *http.Reques
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getEvents(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
sendEvent := func(wf *utils.WriteFlusher, event *utils.JSONMessage) error {
|
||||||
|
b, err := json.Marshal(event)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("JSON error")
|
||||||
|
}
|
||||||
|
_, err = wf.Write(b)
|
||||||
|
if err != nil {
|
||||||
|
// On error, evict the listener
|
||||||
|
utils.Debugf("%s", err)
|
||||||
|
srv.Lock()
|
||||||
|
delete(srv.listeners, r.RemoteAddr)
|
||||||
|
srv.Unlock()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := parseForm(r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
listener := make(chan utils.JSONMessage)
|
||||||
|
srv.Lock()
|
||||||
|
srv.listeners[r.RemoteAddr] = listener
|
||||||
|
srv.Unlock()
|
||||||
|
since, err := strconv.ParseInt(r.Form.Get("since"), 10, 0)
|
||||||
|
if err != nil {
|
||||||
|
since = 0
|
||||||
|
}
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
wf := utils.NewWriteFlusher(w)
|
||||||
|
if since != 0 {
|
||||||
|
// If since, send previous events that happened after the timestamp
|
||||||
|
for _, event := range srv.events {
|
||||||
|
if event.Time >= since {
|
||||||
|
err := sendEvent(wf, &event)
|
||||||
|
if err != nil && err.Error() == "JSON error" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
event := <-listener
|
||||||
|
err := sendEvent(wf, &event)
|
||||||
|
if err != nil && err.Error() == "JSON error" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func getImagesHistory(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func getImagesHistory(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
if vars == nil {
|
if vars == nil {
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
@@ -240,6 +271,30 @@ func getContainersChanges(srv *Server, version float64, w http.ResponseWriter, r
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getContainersTop(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
if version < 1.4 {
|
||||||
|
return fmt.Errorf("top was improved a lot since 1.3, Please upgrade your docker client.")
|
||||||
|
}
|
||||||
|
if vars == nil {
|
||||||
|
return fmt.Errorf("Missing parameter")
|
||||||
|
}
|
||||||
|
if err := parseForm(r); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
name := vars["name"]
|
||||||
|
ps_args := r.Form.Get("ps_args")
|
||||||
|
procsStr, err := srv.ContainerTop(name, ps_args)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
b, err := json.Marshal(procsStr)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
writeJSON(w, b)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
if err := parseForm(r); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -248,6 +303,10 @@ func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *h
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
size, err := getBoolParam(r.Form.Get("size"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
since := r.Form.Get("since")
|
since := r.Form.Get("since")
|
||||||
before := r.Form.Get("before")
|
before := r.Form.Get("before")
|
||||||
n, err := strconv.Atoi(r.Form.Get("limit"))
|
n, err := strconv.Atoi(r.Form.Get("limit"))
|
||||||
@@ -255,7 +314,7 @@ func getContainersJSON(srv *Server, version float64, w http.ResponseWriter, r *h
|
|||||||
n = -1
|
n = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
outs := srv.Containers(all, n, since, before)
|
outs := srv.Containers(all, size, n, since, before)
|
||||||
b, err := json.Marshal(outs)
|
b, err := json.Marshal(outs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -292,7 +351,7 @@ func postCommit(srv *Server, version float64, w http.ResponseWriter, r *http.Req
|
|||||||
}
|
}
|
||||||
config := &Config{}
|
config := &Config{}
|
||||||
if err := json.NewDecoder(r.Body).Decode(config); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(config); err != nil {
|
||||||
utils.Debugf("%s", err.Error())
|
utils.Debugf("%s", err)
|
||||||
}
|
}
|
||||||
repo := r.Form.Get("repo")
|
repo := r.Form.Get("repo")
|
||||||
tag := r.Form.Get("tag")
|
tag := r.Form.Get("tag")
|
||||||
@@ -328,8 +387,7 @@ func postImagesCreate(srv *Server, version float64, w http.ResponseWriter, r *ht
|
|||||||
}
|
}
|
||||||
sf := utils.NewStreamFormatter(version > 1.0)
|
sf := utils.NewStreamFormatter(version > 1.0)
|
||||||
if image != "" { //pull
|
if image != "" { //pull
|
||||||
registry := r.Form.Get("registry")
|
if err := srv.ImagePull(image, tag, w, sf, &auth.AuthConfig{}); err != nil {
|
||||||
if err := srv.ImagePull(image, tag, registry, w, sf, &auth.AuthConfig{}); err != nil {
|
|
||||||
if sf.Used() {
|
if sf.Used() {
|
||||||
w.Write(sf.FormatError(err))
|
w.Write(sf.FormatError(err))
|
||||||
return nil
|
return nil
|
||||||
@@ -398,21 +456,12 @@ func postImagesInsert(srv *Server, version float64, w http.ResponseWriter, r *ht
|
|||||||
|
|
||||||
func postImagesPush(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func postImagesPush(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
authConfig := &auth.AuthConfig{}
|
authConfig := &auth.AuthConfig{}
|
||||||
if version > 1.1 {
|
if err := json.NewDecoder(r.Body).Decode(authConfig); err != nil {
|
||||||
if err := json.NewDecoder(r.Body).Decode(authConfig); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
localAuthConfig, err := auth.LoadConfig(srv.runtime.root)
|
|
||||||
if err != nil && err != auth.ErrConfigFileMissing {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
authConfig = localAuthConfig
|
|
||||||
}
|
}
|
||||||
if err := parseForm(r); err != nil {
|
if err := parseForm(r); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
registry := r.Form.Get("registry")
|
|
||||||
|
|
||||||
if vars == nil {
|
if vars == nil {
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
@@ -422,7 +471,7 @@ func postImagesPush(srv *Server, version float64, w http.ResponseWriter, r *http
|
|||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
}
|
}
|
||||||
sf := utils.NewStreamFormatter(version > 1.0)
|
sf := utils.NewStreamFormatter(version > 1.0)
|
||||||
if err := srv.ImagePush(name, registry, w, sf, authConfig); err != nil {
|
if err := srv.ImagePush(name, w, sf, authConfig); err != nil {
|
||||||
if sf.Used() {
|
if sf.Used() {
|
||||||
w.Write(sf.FormatError(err))
|
w.Write(sf.FormatError(err))
|
||||||
return nil
|
return nil
|
||||||
@@ -521,7 +570,7 @@ func deleteImages(srv *Server, version float64, w http.ResponseWriter, r *http.R
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if imgs != nil {
|
if imgs != nil {
|
||||||
if len(*imgs) != 0 {
|
if len(imgs) != 0 {
|
||||||
b, err := json.Marshal(imgs)
|
b, err := json.Marshal(imgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -537,11 +586,22 @@ func deleteImages(srv *Server, version float64, w http.ResponseWriter, r *http.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func postContainersStart(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
hostConfig := &HostConfig{}
|
||||||
|
|
||||||
|
// allow a nil body for backwards compatibility
|
||||||
|
if r.Body != nil {
|
||||||
|
if r.Header.Get("Content-Type") == "application/json" {
|
||||||
|
if err := json.NewDecoder(r.Body).Decode(hostConfig); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if vars == nil {
|
if vars == nil {
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
name := vars["name"]
|
name := vars["name"]
|
||||||
if err := srv.ContainerStart(name); err != nil {
|
if err := srv.ContainerStart(name, hostConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
@@ -646,7 +706,20 @@ func postContainersAttach(srv *Server, version float64, w http.ResponseWriter, r
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer in.Close()
|
defer func() {
|
||||||
|
if tcpc, ok := in.(*net.TCPConn); ok {
|
||||||
|
tcpc.CloseWrite()
|
||||||
|
} else {
|
||||||
|
in.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
defer func() {
|
||||||
|
if tcpc, ok := out.(*net.TCPConn); ok {
|
||||||
|
tcpc.CloseWrite()
|
||||||
|
} else if closer, ok := out.(io.Closer); ok {
|
||||||
|
closer.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
fmt.Fprintf(out, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
|
fmt.Fprintf(out, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
|
||||||
if err := srv.ContainerAttach(name, logs, stream, stdin, stdout, stderr, in, out); err != nil {
|
if err := srv.ContainerAttach(name, logs, stream, stdin, stdout, stderr, in, out); err != nil {
|
||||||
@@ -715,34 +788,72 @@ func postImagesGetCache(srv *Server, version float64, w http.ResponseWriter, r *
|
|||||||
}
|
}
|
||||||
|
|
||||||
func postBuild(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func postBuild(srv *Server, version float64, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
if err := r.ParseMultipartForm(4096); err != nil {
|
if version < 1.3 {
|
||||||
return err
|
return fmt.Errorf("Multipart upload for build is no longer supported. Please upgrade your docker client.")
|
||||||
}
|
}
|
||||||
remote := r.FormValue("t")
|
remoteURL := r.FormValue("remote")
|
||||||
|
repoName := r.FormValue("t")
|
||||||
|
rawSuppressOutput := r.FormValue("q")
|
||||||
tag := ""
|
tag := ""
|
||||||
if strings.Contains(remote, ":") {
|
if strings.Contains(repoName, ":") {
|
||||||
remoteParts := strings.Split(remote, ":")
|
remoteParts := strings.Split(repoName, ":")
|
||||||
tag = remoteParts[1]
|
tag = remoteParts[1]
|
||||||
remote = remoteParts[0]
|
repoName = remoteParts[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerfile, _, err := r.FormFile("Dockerfile")
|
var context io.Reader
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
context, _, err := r.FormFile("Context")
|
if remoteURL == "" {
|
||||||
if err != nil {
|
context = r.Body
|
||||||
if err != http.ErrMissingFile {
|
} else if utils.IsGIT(remoteURL) {
|
||||||
|
if !strings.HasPrefix(remoteURL, "git://") {
|
||||||
|
remoteURL = "https://" + remoteURL
|
||||||
|
}
|
||||||
|
root, err := ioutil.TempDir("", "docker-build-git")
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
|
if output, err := exec.Command("git", "clone", remoteURL, root).CombinedOutput(); err != nil {
|
||||||
|
return fmt.Errorf("Error trying to use git: %s (%s)", err, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := Tar(root, Bzip2)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
context = c
|
||||||
|
} else if utils.IsURL(remoteURL) {
|
||||||
|
f, err := utils.Download(remoteURL, ioutil.Discard)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.Body.Close()
|
||||||
|
dockerFile, err := ioutil.ReadAll(f.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c, err := mkBuildContext(string(dockerFile), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
context = c
|
||||||
}
|
}
|
||||||
|
|
||||||
b := NewBuildFile(srv, utils.NewWriteFlusher(w))
|
suppressOutput, err := getBoolParam(rawSuppressOutput)
|
||||||
if id, err := b.Build(dockerfile, context); err != nil {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
b := NewBuildFile(srv, utils.NewWriteFlusher(w), !suppressOutput)
|
||||||
|
id, err := b.Build(context)
|
||||||
|
if err != nil {
|
||||||
fmt.Fprintf(w, "Error build: %s\n", err)
|
fmt.Fprintf(w, "Error build: %s\n", err)
|
||||||
} else if remote != "" {
|
return err
|
||||||
srv.runtime.repositories.Set(remote, tag, id, false)
|
}
|
||||||
|
if repoName != "" {
|
||||||
|
srv.runtime.repositories.Set(repoName, tag, id, false)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -762,9 +873,9 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
|||||||
|
|
||||||
m := map[string]map[string]func(*Server, float64, http.ResponseWriter, *http.Request, map[string]string) error{
|
m := map[string]map[string]func(*Server, float64, http.ResponseWriter, *http.Request, map[string]string) error{
|
||||||
"GET": {
|
"GET": {
|
||||||
"/auth": getAuth,
|
"/events": getEvents,
|
||||||
"/version": getVersion,
|
|
||||||
"/info": getInfo,
|
"/info": getInfo,
|
||||||
|
"/version": getVersion,
|
||||||
"/images/json": getImagesJSON,
|
"/images/json": getImagesJSON,
|
||||||
"/images/viz": getImagesViz,
|
"/images/viz": getImagesViz,
|
||||||
"/images/search": getImagesSearch,
|
"/images/search": getImagesSearch,
|
||||||
@@ -775,6 +886,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
|||||||
"/containers/{name:.*}/export": getContainersExport,
|
"/containers/{name:.*}/export": getContainersExport,
|
||||||
"/containers/{name:.*}/changes": getContainersChanges,
|
"/containers/{name:.*}/changes": getContainersChanges,
|
||||||
"/containers/{name:.*}/json": getContainersByName,
|
"/containers/{name:.*}/json": getContainersByName,
|
||||||
|
"/containers/{name:.*}/top": getContainersTop,
|
||||||
},
|
},
|
||||||
"POST": {
|
"POST": {
|
||||||
"/auth": postAuth,
|
"/auth": postAuth,
|
||||||
@@ -811,7 +923,8 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
|||||||
localMethod := method
|
localMethod := method
|
||||||
localFct := fct
|
localFct := fct
|
||||||
f := func(w http.ResponseWriter, r *http.Request) {
|
f := func(w http.ResponseWriter, r *http.Request) {
|
||||||
utils.Debugf("Calling %s %s", localMethod, localRoute)
|
utils.Debugf("Calling %s %s from %s", localMethod, localRoute, r.RemoteAddr)
|
||||||
|
|
||||||
if logging {
|
if logging {
|
||||||
log.Println(r.Method, r.RequestURI)
|
log.Println(r.Method, r.RequestURI)
|
||||||
}
|
}
|
||||||
@@ -832,6 +945,7 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
|||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := localFct(srv, version, w, r, mux.Vars(r)); err != nil {
|
if err := localFct(srv, version, w, r, mux.Vars(r)); err != nil {
|
||||||
httpError(w, err)
|
httpError(w, err)
|
||||||
}
|
}
|
||||||
@@ -848,12 +962,20 @@ func createRouter(srv *Server, logging bool) (*mux.Router, error) {
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListenAndServe(addr string, srv *Server, logging bool) error {
|
func ListenAndServe(proto, addr string, srv *Server, logging bool) error {
|
||||||
log.Printf("Listening for HTTP on %s\n", addr)
|
log.Printf("Listening for HTTP on %s (%s)\n", addr, proto)
|
||||||
|
|
||||||
r, err := createRouter(srv, logging)
|
r, err := createRouter(srv, logging)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return http.ListenAndServe(addr, r)
|
l, e := net.Listen(proto, addr)
|
||||||
|
if e != nil {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
if proto == "unix" {
|
||||||
|
os.Chmod(addr, 0700)
|
||||||
|
}
|
||||||
|
httpSrv := http.Server{Addr: addr, Handler: r}
|
||||||
|
return httpSrv.Serve(l)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
type APIHistory struct {
|
type APIHistory struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
|
Tags []string `json:",omitempty"`
|
||||||
Created int64
|
Created int64
|
||||||
CreatedBy string `json:",omitempty"`
|
CreatedBy string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
@@ -16,13 +17,21 @@ type APIImages struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type APIInfo struct {
|
type APIInfo struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
Containers int
|
Containers int
|
||||||
Images int
|
Images int
|
||||||
NFd int `json:",omitempty"`
|
NFd int `json:",omitempty"`
|
||||||
NGoroutines int `json:",omitempty"`
|
NGoroutines int `json:",omitempty"`
|
||||||
MemoryLimit bool `json:",omitempty"`
|
MemoryLimit bool `json:",omitempty"`
|
||||||
SwapLimit bool `json:",omitempty"`
|
SwapLimit bool `json:",omitempty"`
|
||||||
|
LXCVersion string `json:",omitempty"`
|
||||||
|
NEventsListener int `json:",omitempty"`
|
||||||
|
KernelVersion string `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type APITop struct {
|
||||||
|
Titles []string
|
||||||
|
Processes [][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type APIRmi struct {
|
type APIRmi struct {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/dotcloud/docker/auth"
|
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@@ -17,49 +16,33 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPostAuth(t *testing.T) {
|
func TestGetBoolParam(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
if ret, err := getBoolParam("true"); err != nil || !ret {
|
||||||
if err != nil {
|
t.Fatalf("true -> true, nil | got %t %s", ret, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
}
|
||||||
defer nuke(runtime)
|
if ret, err := getBoolParam("True"); err != nil || !ret {
|
||||||
|
t.Fatalf("True -> true, nil | got %t %s", ret, err)
|
||||||
srv := &Server{
|
|
||||||
runtime: runtime,
|
|
||||||
}
|
}
|
||||||
|
if ret, err := getBoolParam("1"); err != nil || !ret {
|
||||||
r := httptest.NewRecorder()
|
t.Fatalf("1 -> true, nil | got %t %s", ret, err)
|
||||||
|
|
||||||
authConfig := &auth.AuthConfig{
|
|
||||||
Username: "utest",
|
|
||||||
Password: "utest",
|
|
||||||
Email: "utest@yopmail.com",
|
|
||||||
}
|
}
|
||||||
|
if ret, err := getBoolParam(""); err != nil || ret {
|
||||||
authConfigJSON, err := json.Marshal(authConfig)
|
t.Fatalf("\"\" -> false, nil | got %t %s", ret, err)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
if ret, err := getBoolParam("false"); err != nil || ret {
|
||||||
req, err := http.NewRequest("POST", "/auth", bytes.NewReader(authConfigJSON))
|
t.Fatalf("false -> false, nil | got %t %s", ret, err)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
if ret, err := getBoolParam("0"); err != nil || ret {
|
||||||
if err := postAuth(srv, APIVERSION, r, req, nil); err != nil {
|
t.Fatalf("0 -> false, nil | got %t %s", ret, err)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
if ret, err := getBoolParam("faux"); err == nil || ret {
|
||||||
if r.Code != http.StatusOK && r.Code != 0 {
|
t.Fatalf("faux -> false, err | got %t %s", ret, err)
|
||||||
t.Fatalf("%d OK or 0 expected, received %d\n", http.StatusOK, r.Code)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetVersion(t *testing.T) {
|
func TestGetVersion(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
var err error
|
||||||
if err != nil {
|
runtime := mkRuntime(t)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -75,19 +58,21 @@ func TestGetVersion(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if v.Version != VERSION {
|
if v.Version != VERSION {
|
||||||
t.Errorf("Excepted version %s, %s found", VERSION, v.Version)
|
t.Errorf("Expected version %s, %s found", VERSION, v.Version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetInfo(t *testing.T) {
|
func TestGetInfo(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
|
|
||||||
|
initialImages, err := srv.runtime.graph.All()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
r := httptest.NewRecorder()
|
r := httptest.NewRecorder()
|
||||||
|
|
||||||
if err := getInfo(srv, APIVERSION, r, nil, nil); err != nil {
|
if err := getInfo(srv, APIVERSION, r, nil, nil); err != nil {
|
||||||
@@ -99,21 +84,62 @@ func TestGetInfo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if infos.Images != 1 {
|
if infos.Images != len(initialImages) {
|
||||||
t.Errorf("Excepted images: %d, %d found", 1, infos.Images)
|
t.Errorf("Expected images: %d, %d found", len(initialImages), infos.Images)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetImagesJSON(t *testing.T) {
|
func TestGetEvents(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
|
srv := &Server{
|
||||||
|
runtime: runtime,
|
||||||
|
events: make([]utils.JSONMessage, 0, 64),
|
||||||
|
listeners: make(map[string]chan utils.JSONMessage),
|
||||||
|
}
|
||||||
|
|
||||||
|
srv.LogEvent("fakeaction", "fakeid")
|
||||||
|
srv.LogEvent("fakeaction2", "fakeid")
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", "/events?since=1", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r := httptest.NewRecorder()
|
||||||
|
setTimeout(t, "", 500*time.Millisecond, func() {
|
||||||
|
if err := getEvents(srv, APIVERSION, r, req, nil); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
dec := json.NewDecoder(r.Body)
|
||||||
|
for i := 0; i < 2; i++ {
|
||||||
|
var jm utils.JSONMessage
|
||||||
|
if err := dec.Decode(&jm); err == io.EOF {
|
||||||
|
break
|
||||||
|
} else if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if jm != srv.events[i] {
|
||||||
|
t.Fatalf("Event received it different than expected")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetImagesJSON(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
|
|
||||||
// all=0
|
// all=0
|
||||||
|
|
||||||
|
initialImages, err := srv.Images(false, "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/images/json?all=0", nil)
|
req, err := http.NewRequest("GET", "/images/json?all=0", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -130,17 +156,30 @@ func TestGetImagesJSON(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(images) != 1 {
|
if len(images) != len(initialImages) {
|
||||||
t.Errorf("Excepted 1 image, %d found", len(images))
|
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||||
}
|
}
|
||||||
|
|
||||||
if images[0].Repository != unitTestImageName {
|
found := false
|
||||||
t.Errorf("Excepted image %s, %s found", unitTestImageName, images[0].Repository)
|
for _, img := range images {
|
||||||
|
if img.Repository == unitTestImageName {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("Expected image %s, %+v found", unitTestImageName, images)
|
||||||
}
|
}
|
||||||
|
|
||||||
r2 := httptest.NewRecorder()
|
r2 := httptest.NewRecorder()
|
||||||
|
|
||||||
// all=1
|
// all=1
|
||||||
|
|
||||||
|
initialImages, err = srv.Images(true, "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
req2, err := http.NewRequest("GET", "/images/json?all=true", nil)
|
req2, err := http.NewRequest("GET", "/images/json?all=true", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -155,18 +194,25 @@ func TestGetImagesJSON(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(images2) != 1 {
|
if len(images2) != len(initialImages) {
|
||||||
t.Errorf("Excepted 1 image, %d found", len(images2))
|
t.Errorf("Expected %d image, %d found", len(initialImages), len(images2))
|
||||||
}
|
}
|
||||||
|
|
||||||
if images2[0].ID != GetTestImage(runtime).ID {
|
found = false
|
||||||
t.Errorf("Retrieved image Id differs, expected %s, received %s", GetTestImage(runtime).ID, images2[0].ID)
|
for _, img := range images2 {
|
||||||
|
if img.ID == GetTestImage(runtime).ID {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("Retrieved image Id differs, expected %s, received %+v", GetTestImage(runtime).ID, images2)
|
||||||
}
|
}
|
||||||
|
|
||||||
r3 := httptest.NewRecorder()
|
r3 := httptest.NewRecorder()
|
||||||
|
|
||||||
// filter=a
|
// filter=a
|
||||||
req3, err := http.NewRequest("GET", "/images/json?filter=a", nil)
|
req3, err := http.NewRequest("GET", "/images/json?filter=aaaaaaaaaa", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -181,7 +227,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(images3) != 0 {
|
if len(images3) != 0 {
|
||||||
t.Errorf("Excepted 1 image, %d found", len(images3))
|
t.Errorf("Expected 0 image, %d found", len(images3))
|
||||||
}
|
}
|
||||||
|
|
||||||
r4 := httptest.NewRecorder()
|
r4 := httptest.NewRecorder()
|
||||||
@@ -204,10 +250,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetImagesViz(t *testing.T) {
|
func TestGetImagesViz(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -227,46 +270,12 @@ func TestGetImagesViz(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if line != "digraph docker {\n" {
|
if line != "digraph docker {\n" {
|
||||||
t.Errorf("Excepted digraph docker {\n, %s found", line)
|
t.Errorf("Expected digraph docker {\n, %s found", line)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetImagesSearch(t *testing.T) {
|
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{
|
|
||||||
runtime: runtime,
|
|
||||||
}
|
|
||||||
|
|
||||||
r := httptest.NewRecorder()
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/images/search?term=redis", nil)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := getImagesSearch(srv, APIVERSION, r, req, nil); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
results := []APISearch{}
|
|
||||||
if err := json.Unmarshal(r.Body.Bytes(), &results); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if len(results) < 2 {
|
|
||||||
t.Errorf("Excepted at least 2 lines, %d found", len(results))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetImagesHistory(t *testing.T) {
|
func TestGetImagesHistory(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -282,15 +291,12 @@ func TestGetImagesHistory(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if len(history) != 1 {
|
if len(history) != 1 {
|
||||||
t.Errorf("Excepted 1 line, %d found", len(history))
|
t.Errorf("Expected 1 line, %d found", len(history))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetImagesByName(t *testing.T) {
|
func TestGetImagesByName(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -304,16 +310,13 @@ func TestGetImagesByName(t *testing.T) {
|
|||||||
if err := json.Unmarshal(r.Body.Bytes(), img); err != nil {
|
if err := json.Unmarshal(r.Body.Bytes(), img); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if img.ID != GetTestImage(runtime).ID || img.Comment != "Imported from http://get.docker.io/images/busybox" {
|
if img.ID != unitTestImageID {
|
||||||
t.Errorf("Error inspecting image")
|
t.Errorf("Error inspecting image")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContainersJSON(t *testing.T) {
|
func TestGetContainersJSON(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -341,7 +344,7 @@ func TestGetContainersJSON(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if len(containers) != 1 {
|
if len(containers) != 1 {
|
||||||
t.Fatalf("Excepted %d container, %d found", 1, len(containers))
|
t.Fatalf("Expected %d container, %d found", 1, len(containers))
|
||||||
}
|
}
|
||||||
if containers[0].ID != container.ID {
|
if containers[0].ID != container.ID {
|
||||||
t.Fatalf("Container ID mismatch. Expected: %s, received: %s\n", container.ID, containers[0].ID)
|
t.Fatalf("Container ID mismatch. Expected: %s, received: %s\n", container.ID, containers[0].ID)
|
||||||
@@ -349,10 +352,7 @@ func TestGetContainersJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContainersExport(t *testing.T) {
|
func TestGetContainersExport(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -404,10 +404,7 @@ func TestGetContainersExport(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContainersChanges(t *testing.T) {
|
func TestGetContainersChanges(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -451,7 +448,7 @@ func TestGetContainersChanges(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetContainersByName(t *testing.T) {
|
func TestGetContainersTop(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime, err := newTestRuntime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -462,6 +459,67 @@ func TestGetContainersByName(t *testing.T) {
|
|||||||
|
|
||||||
builder := NewBuilder(runtime)
|
builder := NewBuilder(runtime)
|
||||||
|
|
||||||
|
container, err := builder.Create(
|
||||||
|
&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"/bin/sh", "-c", "sleep 2"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give some time to the process to start
|
||||||
|
container.WaitTimeout(500 * time.Millisecond)
|
||||||
|
|
||||||
|
if !container.State.Running {
|
||||||
|
t.Errorf("Container should be running")
|
||||||
|
}
|
||||||
|
|
||||||
|
r := httptest.NewRecorder()
|
||||||
|
req, err := http.NewRequest("GET", "/"+container.ID+"/top?ps_args=u", bytes.NewReader([]byte{}))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := getContainersTop(srv, APIVERSION, r, req, map[string]string{"name": container.ID}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
procs := APITop{}
|
||||||
|
if err := json.Unmarshal(r.Body.Bytes(), &procs); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(procs.Titles) != 11 {
|
||||||
|
t.Fatalf("Expected 11 titles, found %d.", len(procs.Titles))
|
||||||
|
}
|
||||||
|
if procs.Titles[0] != "USER" || procs.Titles[10] != "COMMAND" {
|
||||||
|
t.Fatalf("Expected Titles[0] to be USER and Titles[10] to be COMMAND, found %s and %s.", procs.Titles[0], procs.Titles[10])
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(procs.Processes) != 2 {
|
||||||
|
t.Fatalf("Expected 2 processes, found %d.", len(procs.Processes))
|
||||||
|
}
|
||||||
|
if procs.Processes[0][10] != "/bin/sh" && procs.Processes[0][10] != "sleep" {
|
||||||
|
t.Fatalf("Expected `sleep` or `/bin/sh`, found %s.", procs.Processes[0][10])
|
||||||
|
}
|
||||||
|
if procs.Processes[1][10] != "/bin/sh" && procs.Processes[1][10] != "sleep" {
|
||||||
|
t.Fatalf("Expected `sleep` or `/bin/sh`, found %s.", procs.Processes[1][10])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetContainersByName(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
srv := &Server{runtime: runtime}
|
||||||
|
|
||||||
|
builder := NewBuilder(runtime)
|
||||||
|
|
||||||
// Create a container and remove a file
|
// Create a container and remove a file
|
||||||
container, err := builder.Create(
|
container, err := builder.Create(
|
||||||
&Config{
|
&Config{
|
||||||
@@ -488,10 +546,7 @@ func TestGetContainersByName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostCommit(t *testing.T) {
|
func TestPostCommit(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -536,249 +591,8 @@ func TestPostCommit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPostImagesCreate(t *testing.T) {
|
|
||||||
// FIXME: Use the staging in order to perform tests
|
|
||||||
|
|
||||||
// runtime, err := newTestRuntime()
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// defer nuke(runtime)
|
|
||||||
|
|
||||||
// srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
// stdin, stdinPipe := io.Pipe()
|
|
||||||
// stdout, stdoutPipe := io.Pipe()
|
|
||||||
|
|
||||||
// c1 := make(chan struct{})
|
|
||||||
// go func() {
|
|
||||||
// defer close(c1)
|
|
||||||
|
|
||||||
// r := &hijackTester{
|
|
||||||
// ResponseRecorder: httptest.NewRecorder(),
|
|
||||||
// in: stdin,
|
|
||||||
// out: stdoutPipe,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// req, err := http.NewRequest("POST", "/images/create?fromImage="+unitTestImageName, bytes.NewReader([]byte{}))
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// body, err := postImagesCreate(srv, r, req, nil)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// if body != nil {
|
|
||||||
// t.Fatalf("No body expected, received: %s\n", body)
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
|
|
||||||
// // Acknowledge hijack
|
|
||||||
// setTimeout(t, "hijack acknowledge timed out", 2*time.Second, func() {
|
|
||||||
// stdout.Read([]byte{})
|
|
||||||
// stdout.Read(make([]byte, 4096))
|
|
||||||
// })
|
|
||||||
|
|
||||||
// setTimeout(t, "Waiting for imagesCreate output", 5*time.Second, func() {
|
|
||||||
// reader := bufio.NewReader(stdout)
|
|
||||||
// line, err := reader.ReadString('\n')
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// if !strings.HasPrefix(line, "Pulling repository d from") {
|
|
||||||
// t.Fatalf("Expected Pulling repository docker-ut from..., found %s", line)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// // Close pipes (client disconnects)
|
|
||||||
// if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Wait for imagesCreate to finish, the client disconnected, therefore, Create finished his job
|
|
||||||
// setTimeout(t, "Waiting for imagesCreate timed out", 10*time.Second, func() {
|
|
||||||
// <-c1
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPostImagesInsert(t *testing.T) {
|
|
||||||
// runtime, err := newTestRuntime()
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// defer nuke(runtime)
|
|
||||||
|
|
||||||
// srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
// stdin, stdinPipe := io.Pipe()
|
|
||||||
// stdout, stdoutPipe := io.Pipe()
|
|
||||||
|
|
||||||
// // Attach to it
|
|
||||||
// c1 := make(chan struct{})
|
|
||||||
// go func() {
|
|
||||||
// defer close(c1)
|
|
||||||
// r := &hijackTester{
|
|
||||||
// ResponseRecorder: httptest.NewRecorder(),
|
|
||||||
// in: stdin,
|
|
||||||
// out: stdoutPipe,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// req, err := http.NewRequest("POST", "/images/"+unitTestImageName+"/insert?path=%2Ftest&url=https%3A%2F%2Fraw.github.com%2Fdotcloud%2Fdocker%2Fmaster%2FREADME.md", bytes.NewReader([]byte{}))
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// if err := postContainersCreate(srv, r, req, nil); err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
|
|
||||||
// // Acknowledge hijack
|
|
||||||
// setTimeout(t, "hijack acknowledge timed out", 5*time.Second, func() {
|
|
||||||
// stdout.Read([]byte{})
|
|
||||||
// stdout.Read(make([]byte, 4096))
|
|
||||||
// })
|
|
||||||
|
|
||||||
// id := ""
|
|
||||||
// setTimeout(t, "Waiting for imagesInsert output", 10*time.Second, func() {
|
|
||||||
// for {
|
|
||||||
// reader := bufio.NewReader(stdout)
|
|
||||||
// id, err = reader.ReadString('\n')
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// // Close pipes (client disconnects)
|
|
||||||
// if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Wait for attach to finish, the client disconnected, therefore, Attach finished his job
|
|
||||||
// setTimeout(t, "Waiting for CmdAttach timed out", 2*time.Second, func() {
|
|
||||||
// <-c1
|
|
||||||
// })
|
|
||||||
|
|
||||||
// img, err := srv.runtime.repositories.LookupImage(id)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatalf("New image %s expected but not found", id)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// layer, err := img.layer()
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if _, err := os.Stat(path.Join(layer, "test")); err != nil {
|
|
||||||
// t.Fatalf("The test file has not been found")
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if err := srv.runtime.graph.Delete(img.ID); err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPostImagesPush(t *testing.T) {
|
|
||||||
//FIXME: Use staging in order to perform tests
|
|
||||||
// runtime, err := newTestRuntime()
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// defer nuke(runtime)
|
|
||||||
|
|
||||||
// srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
// stdin, stdinPipe := io.Pipe()
|
|
||||||
// stdout, stdoutPipe := io.Pipe()
|
|
||||||
|
|
||||||
// c1 := make(chan struct{})
|
|
||||||
// go func() {
|
|
||||||
// r := &hijackTester{
|
|
||||||
// ResponseRecorder: httptest.NewRecorder(),
|
|
||||||
// in: stdin,
|
|
||||||
// out: stdoutPipe,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// req, err := http.NewRequest("POST", "/images/docker-ut/push", bytes.NewReader([]byte{}))
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// body, err := postImagesPush(srv, r, req, map[string]string{"name": "docker-ut"})
|
|
||||||
// close(c1)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// if body != nil {
|
|
||||||
// t.Fatalf("No body expected, received: %s\n", body)
|
|
||||||
// }
|
|
||||||
// }()
|
|
||||||
|
|
||||||
// // Acknowledge hijack
|
|
||||||
// setTimeout(t, "hijack acknowledge timed out", 2*time.Second, func() {
|
|
||||||
// stdout.Read([]byte{})
|
|
||||||
// stdout.Read(make([]byte, 4096))
|
|
||||||
// })
|
|
||||||
|
|
||||||
// setTimeout(t, "Waiting for imagesCreate output", 5*time.Second, func() {
|
|
||||||
// reader := bufio.NewReader(stdout)
|
|
||||||
// line, err := reader.ReadString('\n')
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// if !strings.HasPrefix(line, "Processing checksum") {
|
|
||||||
// t.Fatalf("Processing checksum..., found %s", line)
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
// // Close pipes (client disconnects)
|
|
||||||
// if err := closeWrap(stdin, stdinPipe, stdout, stdoutPipe); err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Wait for imagesPush to finish, the client disconnected, therefore, Push finished his job
|
|
||||||
// setTimeout(t, "Waiting for imagesPush timed out", 10*time.Second, func() {
|
|
||||||
// <-c1
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPostImagesTag(t *testing.T) {
|
|
||||||
// FIXME: Use staging in order to perform tests
|
|
||||||
|
|
||||||
// runtime, err := newTestRuntime()
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// defer nuke(runtime)
|
|
||||||
|
|
||||||
// srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
// r := httptest.NewRecorder()
|
|
||||||
|
|
||||||
// req, err := http.NewRequest("POST", "/images/docker-ut/tag?repo=testrepo&tag=testtag", bytes.NewReader([]byte{}))
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// body, err := postImagesTag(srv, r, req, map[string]string{"name": "docker-ut"})
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if body != nil {
|
|
||||||
// t.Fatalf("No body expected, received: %s\n", body)
|
|
||||||
// }
|
|
||||||
// if r.Code != http.StatusCreated {
|
|
||||||
// t.Fatalf("%d Created expected, received %d\n", http.StatusCreated, r.Code)
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPostContainersCreate(t *testing.T) {
|
func TestPostContainersCreate(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -829,10 +643,7 @@ func TestPostContainersCreate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostContainersKill(t *testing.T) {
|
func TestPostContainersKill(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -849,7 +660,8 @@ func TestPostContainersKill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,10 +685,7 @@ func TestPostContainersKill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostContainersRestart(t *testing.T) {
|
func TestPostContainersRestart(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -893,7 +702,8 @@ func TestPostContainersRestart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -929,10 +739,7 @@ func TestPostContainersRestart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostContainersStart(t *testing.T) {
|
func TestPostContainersStart(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -949,8 +756,15 @@ func TestPostContainersStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
|
hostConfigJSON, err := json.Marshal(&HostConfig{})
|
||||||
|
|
||||||
|
req, err := http.NewRequest("POST", "/containers/"+container.ID+"/start", bytes.NewReader(hostConfigJSON))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
r := httptest.NewRecorder()
|
r := httptest.NewRecorder()
|
||||||
if err := postContainersStart(srv, APIVERSION, r, nil, map[string]string{"name": container.ID}); err != nil {
|
if err := postContainersStart(srv, APIVERSION, r, req, map[string]string{"name": container.ID}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if r.Code != http.StatusNoContent {
|
if r.Code != http.StatusNoContent {
|
||||||
@@ -965,7 +779,7 @@ func TestPostContainersStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = httptest.NewRecorder()
|
r = httptest.NewRecorder()
|
||||||
if err = postContainersStart(srv, APIVERSION, r, nil, map[string]string{"name": container.ID}); err == nil {
|
if err = postContainersStart(srv, APIVERSION, r, req, map[string]string{"name": container.ID}); err == nil {
|
||||||
t.Fatalf("A running containter should be able to be started")
|
t.Fatalf("A running containter should be able to be started")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -975,10 +789,7 @@ func TestPostContainersStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostContainersStop(t *testing.T) {
|
func TestPostContainersStop(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -995,7 +806,8 @@ func TestPostContainersStop(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1024,10 +836,7 @@ func TestPostContainersStop(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostContainersWait(t *testing.T) {
|
func TestPostContainersWait(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -1044,7 +853,8 @@ func TestPostContainersWait(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1068,10 +878,7 @@ func TestPostContainersWait(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPostContainersAttach(t *testing.T) {
|
func TestPostContainersAttach(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -1089,13 +896,20 @@ func TestPostContainersAttach(t *testing.T) {
|
|||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
// Start the process
|
// Start the process
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
stdin, stdinPipe := io.Pipe()
|
stdin, stdinPipe := io.Pipe()
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
// Try to avoid the timeoout in destroy. Best effort, don't check error
|
||||||
|
defer func() {
|
||||||
|
closeWrap(stdin, stdinPipe, stdout, stdoutPipe)
|
||||||
|
container.Kill()
|
||||||
|
}()
|
||||||
|
|
||||||
// Attach to it
|
// Attach to it
|
||||||
c1 := make(chan struct{})
|
c1 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
@@ -1135,7 +949,7 @@ func TestPostContainersAttach(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for attach to finish, the client disconnected, therefore, Attach finished his job
|
// Wait for attach to finish, the client disconnected, therefore, Attach finished his job
|
||||||
setTimeout(t, "Waiting for CmdAttach timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for CmdAttach timed out", 10*time.Second, func() {
|
||||||
<-c1
|
<-c1
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1156,10 +970,7 @@ func TestPostContainersAttach(t *testing.T) {
|
|||||||
// FIXME: Test deleting container with volume
|
// FIXME: Test deleting container with volume
|
||||||
// FIXME: Test deleting volume in use by other container
|
// FIXME: Test deleting volume in use by other container
|
||||||
func TestDeleteContainers(t *testing.T) {
|
func TestDeleteContainers(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
@@ -1199,10 +1010,7 @@ func TestDeleteContainers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOptionsRoute(t *testing.T) {
|
func TestOptionsRoute(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime, enableCors: true}
|
srv := &Server{runtime: runtime, enableCors: true}
|
||||||
@@ -1225,10 +1033,7 @@ func TestOptionsRoute(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetEnabledCors(t *testing.T) {
|
func TestGetEnabledCors(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime, enableCors: true}
|
srv := &Server{runtime: runtime, enableCors: true}
|
||||||
@@ -1266,14 +1071,16 @@ func TestGetEnabledCors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteImages(t *testing.T) {
|
func TestDeleteImages(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
srv := &Server{runtime: runtime}
|
||||||
|
|
||||||
|
initialImages, err := srv.Images(false, "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := srv.runtime.repositories.Set("test", "test", unitTestImageName, true); err != nil {
|
if err := srv.runtime.repositories.Set("test", "test", unitTestImageName, true); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -1283,25 +1090,35 @@ func TestDeleteImages(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(images) != 2 {
|
if len(images) != len(initialImages)+1 {
|
||||||
t.Errorf("Excepted 2 images, %d found", len(images))
|
t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images))
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("DELETE", "/images/test:test", nil)
|
req, err := http.NewRequest("DELETE", "/images/"+unitTestImageID, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r := httptest.NewRecorder()
|
r := httptest.NewRecorder()
|
||||||
if err := deleteImages(srv, APIVERSION, r, req, map[string]string{"name": "test:test"}); err != nil {
|
if err := deleteImages(srv, APIVERSION, r, req, map[string]string{"name": unitTestImageID}); err == nil {
|
||||||
|
t.Fatalf("Expected conflict error, got none")
|
||||||
|
}
|
||||||
|
|
||||||
|
req2, err := http.NewRequest("DELETE", "/images/test:test", nil)
|
||||||
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if r.Code != http.StatusOK {
|
|
||||||
|
r2 := httptest.NewRecorder()
|
||||||
|
if err := deleteImages(srv, APIVERSION, r2, req2, map[string]string{"name": "test:test"}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if r2.Code != http.StatusOK {
|
||||||
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
var outs []APIRmi
|
var outs []APIRmi
|
||||||
if err := json.Unmarshal(r.Body.Bytes(), &outs); err != nil {
|
if err := json.Unmarshal(r2.Body.Bytes(), &outs); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if len(outs) != 1 {
|
if len(outs) != 1 {
|
||||||
@@ -1312,8 +1129,8 @@ func TestDeleteImages(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(images) != 1 {
|
if len(images) != len(initialImages) {
|
||||||
t.Errorf("Excepted 1 image, %d found", len(images))
|
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if c := runtime.Get(container.Id); c != nil {
|
/* if c := runtime.Get(container.Id); c != nil {
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"archive/tar"
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/dotcloud/docker/utils"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Archive io.Reader
|
type Archive io.Reader
|
||||||
@@ -20,6 +24,33 @@ const (
|
|||||||
Xz
|
Xz
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func DetectCompression(source []byte) Compression {
|
||||||
|
sourceLen := len(source)
|
||||||
|
for compression, m := range map[Compression][]byte{
|
||||||
|
Bzip2: {0x42, 0x5A, 0x68},
|
||||||
|
Gzip: {0x1F, 0x8B, 0x08},
|
||||||
|
Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00},
|
||||||
|
} {
|
||||||
|
fail := false
|
||||||
|
if len(m) > sourceLen {
|
||||||
|
utils.Debugf("Len too short")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
i := 0
|
||||||
|
for _, b := range m {
|
||||||
|
if b != source[i] {
|
||||||
|
fail = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
if !fail {
|
||||||
|
return compression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Uncompressed
|
||||||
|
}
|
||||||
|
|
||||||
func (compression *Compression) Flag() string {
|
func (compression *Compression) Flag() string {
|
||||||
switch *compression {
|
switch *compression {
|
||||||
case Bzip2:
|
case Bzip2:
|
||||||
@@ -46,15 +77,54 @@ func (compression *Compression) Extension() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tar creates an archive from the directory at `path`, and returns it as a
|
||||||
|
// stream of bytes.
|
||||||
func Tar(path string, compression Compression) (io.Reader, error) {
|
func Tar(path string, compression Compression) (io.Reader, error) {
|
||||||
cmd := exec.Command("bsdtar", "-f", "-", "-C", path, "-c"+compression.Flag(), ".")
|
return TarFilter(path, compression, nil)
|
||||||
return CmdStream(cmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tar creates an archive from the directory at `path`, only including files whose relative
|
||||||
|
// paths are included in `filter`. If `filter` is nil, then all files are included.
|
||||||
|
func TarFilter(path string, compression Compression, filter []string) (io.Reader, error) {
|
||||||
|
args := []string{"tar", "--numeric-owner", "-f", "-", "-C", path}
|
||||||
|
if filter == nil {
|
||||||
|
filter = []string{"."}
|
||||||
|
}
|
||||||
|
for _, f := range filter {
|
||||||
|
args = append(args, "-c"+compression.Flag(), f)
|
||||||
|
}
|
||||||
|
return CmdStream(exec.Command(args[0], args[1:]...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Untar reads a stream of bytes from `archive`, parses it as a tar archive,
|
||||||
|
// and unpacks it into the directory at `path`.
|
||||||
|
// The archive may be compressed with one of the following algorithgms:
|
||||||
|
// identity (uncompressed), gzip, bzip2, xz.
|
||||||
// FIXME: specify behavior when target path exists vs. doesn't exist.
|
// FIXME: specify behavior when target path exists vs. doesn't exist.
|
||||||
func Untar(archive io.Reader, path string) error {
|
func Untar(archive io.Reader, path string) error {
|
||||||
cmd := exec.Command("bsdtar", "-f", "-", "-C", path, "-x")
|
if archive == nil {
|
||||||
cmd.Stdin = archive
|
return fmt.Errorf("Empty archive")
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := make([]byte, 10)
|
||||||
|
totalN := 0
|
||||||
|
for totalN < 10 {
|
||||||
|
if n, err := archive.Read(buf[totalN:]); err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
return fmt.Errorf("Tarball too short")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
totalN += n
|
||||||
|
utils.Debugf("[tar autodetect] n: %d", n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compression := DetectCompression(buf)
|
||||||
|
|
||||||
|
utils.Debugf("Archive compression detected: %s", compression.Extension())
|
||||||
|
|
||||||
|
cmd := exec.Command("tar", "--numeric-owner", "-f", "-", "-C", path, "-x"+compression.Flag())
|
||||||
|
cmd.Stdin = io.MultiReader(bytes.NewReader(buf), archive)
|
||||||
// Hardcode locale environment for predictable outcome regardless of host configuration.
|
// Hardcode locale environment for predictable outcome regardless of host configuration.
|
||||||
// (see https://github.com/dotcloud/docker/issues/355)
|
// (see https://github.com/dotcloud/docker/issues/355)
|
||||||
cmd.Env = []string{"LANG=en_US.utf-8", "LC_ALL=en_US.utf-8"}
|
cmd.Env = []string{"LANG=en_US.utf-8", "LC_ALL=en_US.utf-8"}
|
||||||
@@ -65,6 +135,18 @@ func Untar(archive io.Reader, path string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TarUntar is a convenience function which calls Tar and Untar, with
|
||||||
|
// the output of one piped into the other. If either Tar or Untar fails,
|
||||||
|
// TarUntar aborts and returns the error.
|
||||||
|
func TarUntar(src string, filter []string, dst string) error {
|
||||||
|
utils.Debugf("TarUntar(%s %s %s)", src, filter, dst)
|
||||||
|
archive, err := TarFilter(src, Uncompressed, filter)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return Untar(archive, dst)
|
||||||
|
}
|
||||||
|
|
||||||
// UntarPath is a convenience function which looks for an archive
|
// UntarPath is a convenience function which looks for an archive
|
||||||
// at filesystem path `src`, and unpacks it at `dst`.
|
// at filesystem path `src`, and unpacks it at `dst`.
|
||||||
func UntarPath(src, dst string) error {
|
func UntarPath(src, dst string) error {
|
||||||
@@ -82,11 +164,64 @@ func UntarPath(src, dst string) error {
|
|||||||
// intermediary disk IO.
|
// intermediary disk IO.
|
||||||
//
|
//
|
||||||
func CopyWithTar(src, dst string) error {
|
func CopyWithTar(src, dst string) error {
|
||||||
archive, err := Tar(src, Uncompressed)
|
srcSt, err := os.Stat(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return Untar(archive, dst)
|
if !srcSt.IsDir() {
|
||||||
|
return CopyFileWithTar(src, dst)
|
||||||
|
}
|
||||||
|
// Create dst, copy src's content into it
|
||||||
|
utils.Debugf("Creating dest directory: %s", dst)
|
||||||
|
if err := os.MkdirAll(dst, 0700); err != nil && !os.IsExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
utils.Debugf("Calling TarUntar(%s, %s)", src, dst)
|
||||||
|
return TarUntar(src, nil, dst)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopyFileWithTar emulates the behavior of the 'cp' command-line
|
||||||
|
// for a single file. It copies a regular file from path `src` to
|
||||||
|
// path `dst`, and preserves all its metadata.
|
||||||
|
//
|
||||||
|
// If `dst` ends with a trailing slash '/', the final destination path
|
||||||
|
// will be `dst/base(src)`.
|
||||||
|
func CopyFileWithTar(src, dst string) error {
|
||||||
|
utils.Debugf("CopyFileWithTar(%s, %s)", src, dst)
|
||||||
|
srcSt, err := os.Stat(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if srcSt.IsDir() {
|
||||||
|
return fmt.Errorf("Can't copy a directory")
|
||||||
|
}
|
||||||
|
// Clean up the trailing /
|
||||||
|
if dst[len(dst)-1] == '/' {
|
||||||
|
dst = path.Join(dst, filepath.Base(src))
|
||||||
|
}
|
||||||
|
// Create the holding directory if necessary
|
||||||
|
if err := os.MkdirAll(filepath.Dir(dst), 0700); err != nil && !os.IsExist(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
tw := tar.NewWriter(buf)
|
||||||
|
hdr, err := tar.FileInfoHeader(srcSt, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
hdr.Name = filepath.Base(dst)
|
||||||
|
if err := tw.WriteHeader(hdr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
srcF, err := os.Open(src)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := io.Copy(tw, srcF); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tw.Close()
|
||||||
|
return Untar(buf, filepath.Dir(dst))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CmdStream executes a command, and returns its stdout as a stream.
|
// CmdStream executes a command, and returns its stdout as a stream.
|
||||||
@@ -119,7 +254,7 @@ func CmdStream(cmd *exec.Cmd) (io.Reader, error) {
|
|||||||
}
|
}
|
||||||
errText := <-errChan
|
errText := <-errChan
|
||||||
if err := cmd.Wait(); err != nil {
|
if err := cmd.Wait(); err != nil {
|
||||||
pipeW.CloseWithError(errors.New(err.Error() + ": " + string(errText)))
|
pipeW.CloseWithError(fmt.Errorf("%s: %s", err, errText))
|
||||||
} else {
|
} else {
|
||||||
pipeW.Close()
|
pipeW.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -13,7 +16,7 @@ func TestCmdStreamLargeStderr(t *testing.T) {
|
|||||||
cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello")
|
cmd := exec.Command("/bin/sh", "-c", "dd if=/dev/zero bs=1k count=1000 of=/dev/stderr; echo hello")
|
||||||
out, err := CmdStream(cmd)
|
out, err := CmdStream(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to start command: " + err.Error())
|
t.Fatalf("Failed to start command: %s", err)
|
||||||
}
|
}
|
||||||
errCh := make(chan error)
|
errCh := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -23,7 +26,7 @@ func TestCmdStreamLargeStderr(t *testing.T) {
|
|||||||
select {
|
select {
|
||||||
case err := <-errCh:
|
case err := <-errCh:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Command should not have failed (err=%s...)", err.Error()[:100])
|
t.Fatalf("Command should not have failed (err=%.100s...)", err)
|
||||||
}
|
}
|
||||||
case <-time.After(5 * time.Second):
|
case <-time.After(5 * time.Second):
|
||||||
t.Fatalf("Command did not complete in 5 seconds; probable deadlock")
|
t.Fatalf("Command did not complete in 5 seconds; probable deadlock")
|
||||||
@@ -34,12 +37,12 @@ func TestCmdStreamBad(t *testing.T) {
|
|||||||
badCmd := exec.Command("/bin/sh", "-c", "echo hello; echo >&2 error couldn\\'t reverse the phase pulser; exit 1")
|
badCmd := exec.Command("/bin/sh", "-c", "echo hello; echo >&2 error couldn\\'t reverse the phase pulser; exit 1")
|
||||||
out, err := CmdStream(badCmd)
|
out, err := CmdStream(badCmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to start command: " + err.Error())
|
t.Fatalf("Failed to start command: %s", err)
|
||||||
}
|
}
|
||||||
if output, err := ioutil.ReadAll(out); err == nil {
|
if output, err := ioutil.ReadAll(out); err == nil {
|
||||||
t.Fatalf("Command should have failed")
|
t.Fatalf("Command should have failed")
|
||||||
} else if err.Error() != "exit status 1: error couldn't reverse the phase pulser\n" {
|
} else if err.Error() != "exit status 1: error couldn't reverse the phase pulser\n" {
|
||||||
t.Fatalf("Wrong error value (%s)", err.Error())
|
t.Fatalf("Wrong error value (%s)", err)
|
||||||
} else if s := string(output); s != "hello\n" {
|
} else if s := string(output); s != "hello\n" {
|
||||||
t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output)
|
t.Fatalf("Command output should be '%s', not '%s'", "hello\\n", output)
|
||||||
}
|
}
|
||||||
@@ -58,20 +61,58 @@ func TestCmdStreamGood(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTarUntar(t *testing.T) {
|
func tarUntar(t *testing.T, origin string, compression Compression) error {
|
||||||
archive, err := Tar(".", Uncompressed)
|
archive, err := Tar(origin, compression)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf := make([]byte, 10)
|
||||||
|
if _, err := archive.Read(buf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
archive = io.MultiReader(bytes.NewReader(buf), archive)
|
||||||
|
|
||||||
|
detectedCompression := DetectCompression(buf)
|
||||||
|
if detectedCompression.Extension() != compression.Extension() {
|
||||||
|
return fmt.Errorf("Wrong compression detected. Actual compression: %s, found %s", compression.Extension(), detectedCompression.Extension())
|
||||||
|
}
|
||||||
|
|
||||||
tmp, err := ioutil.TempDir("", "docker-test-untar")
|
tmp, err := ioutil.TempDir("", "docker-test-untar")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmp)
|
defer os.RemoveAll(tmp)
|
||||||
if err := Untar(archive, tmp); err != nil {
|
if err := Untar(archive, tmp); err != nil {
|
||||||
t.Fatal(err)
|
return err
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(tmp); err != nil {
|
if _, err := os.Stat(tmp); err != nil {
|
||||||
t.Fatalf("Error stating %s: %s", tmp, err.Error())
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTarUntar(t *testing.T) {
|
||||||
|
origin, err := ioutil.TempDir("", "docker-test-untar-origin")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(origin)
|
||||||
|
if err := ioutil.WriteFile(path.Join(origin, "1"), []byte("hello world"), 0700); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := ioutil.WriteFile(path.Join(origin, "2"), []byte("welcome!"), 0700); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range []Compression{
|
||||||
|
Uncompressed,
|
||||||
|
Gzip,
|
||||||
|
Bzip2,
|
||||||
|
Xz,
|
||||||
|
} {
|
||||||
|
if err := tarUntar(t, origin, c); err != nil {
|
||||||
|
t.Fatalf("Error tar/untar for compression %s: %s", c.Extension(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import (
|
|||||||
// Where we store the config file
|
// Where we store the config file
|
||||||
const CONFIGFILE = ".dockercfg"
|
const CONFIGFILE = ".dockercfg"
|
||||||
|
|
||||||
// the registry server we want to login against
|
// Only used for user auth + account creation
|
||||||
const INDEXSERVER = "https://index.docker.io/v1"
|
const INDEXSERVER = "https://index.docker.io/v1/"
|
||||||
|
|
||||||
//const INDEXSERVER = "http://indexstaging-docker.dotcloud.com/"
|
//const INDEXSERVER = "http://indexstaging-docker.dotcloud.com/"
|
||||||
|
|
||||||
@@ -25,25 +25,18 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AuthConfig struct {
|
type AuthConfig struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username,omitempty"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password,omitempty"`
|
||||||
|
Auth string `json:"auth"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ConfigFile struct {
|
||||||
|
Configs map[string]AuthConfig `json:"configs,omitempty"`
|
||||||
rootPath string
|
rootPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAuthConfig(username, password, email, rootPath string) *AuthConfig {
|
|
||||||
return &AuthConfig{
|
|
||||||
Username: username,
|
|
||||||
Password: password,
|
|
||||||
Email: email,
|
|
||||||
rootPath: rootPath,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func IndexServerAddress() string {
|
func IndexServerAddress() string {
|
||||||
if os.Getenv("DOCKER_INDEX_URL") != "" {
|
|
||||||
return os.Getenv("DOCKER_INDEX_URL") + "/v1"
|
|
||||||
}
|
|
||||||
return INDEXSERVER
|
return INDEXSERVER
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,62 +50,89 @@ func encodeAuth(authConfig *AuthConfig) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// decode the auth string
|
// decode the auth string
|
||||||
func decodeAuth(authStr string) (*AuthConfig, error) {
|
func decodeAuth(authStr string) (string, string, error) {
|
||||||
decLen := base64.StdEncoding.DecodedLen(len(authStr))
|
decLen := base64.StdEncoding.DecodedLen(len(authStr))
|
||||||
decoded := make([]byte, decLen)
|
decoded := make([]byte, decLen)
|
||||||
authByte := []byte(authStr)
|
authByte := []byte(authStr)
|
||||||
n, err := base64.StdEncoding.Decode(decoded, authByte)
|
n, err := base64.StdEncoding.Decode(decoded, authByte)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", "", err
|
||||||
}
|
}
|
||||||
if n > decLen {
|
if n > decLen {
|
||||||
return nil, fmt.Errorf("Something went wrong decoding auth config")
|
return "", "", fmt.Errorf("Something went wrong decoding auth config")
|
||||||
}
|
}
|
||||||
arr := strings.Split(string(decoded), ":")
|
arr := strings.Split(string(decoded), ":")
|
||||||
if len(arr) != 2 {
|
if len(arr) != 2 {
|
||||||
return nil, fmt.Errorf("Invalid auth configuration file")
|
return "", "", fmt.Errorf("Invalid auth configuration file")
|
||||||
}
|
}
|
||||||
password := strings.Trim(arr[1], "\x00")
|
password := strings.Trim(arr[1], "\x00")
|
||||||
return &AuthConfig{Username: arr[0], Password: password}, nil
|
return arr[0], password, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load up the auth config information and return values
|
// load up the auth config information and return values
|
||||||
// FIXME: use the internal golang config parser
|
// FIXME: use the internal golang config parser
|
||||||
func LoadConfig(rootPath string) (*AuthConfig, error) {
|
func LoadConfig(rootPath string) (*ConfigFile, error) {
|
||||||
|
configFile := ConfigFile{Configs: make(map[string]AuthConfig), rootPath: rootPath}
|
||||||
confFile := path.Join(rootPath, CONFIGFILE)
|
confFile := path.Join(rootPath, CONFIGFILE)
|
||||||
if _, err := os.Stat(confFile); err != nil {
|
if _, err := os.Stat(confFile); err != nil {
|
||||||
return &AuthConfig{rootPath:rootPath}, ErrConfigFileMissing
|
return &configFile, ErrConfigFileMissing
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadFile(confFile)
|
b, err := ioutil.ReadFile(confFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
arr := strings.Split(string(b), "\n")
|
|
||||||
if len(arr) < 2 {
|
if err := json.Unmarshal(b, &configFile.Configs); err != nil {
|
||||||
return nil, fmt.Errorf("The Auth config file is empty")
|
arr := strings.Split(string(b), "\n")
|
||||||
|
if len(arr) < 2 {
|
||||||
|
return nil, fmt.Errorf("The Auth config file is empty")
|
||||||
|
}
|
||||||
|
authConfig := AuthConfig{}
|
||||||
|
origAuth := strings.Split(arr[0], " = ")
|
||||||
|
authConfig.Username, authConfig.Password, err = decodeAuth(origAuth[1])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
origEmail := strings.Split(arr[1], " = ")
|
||||||
|
authConfig.Email = origEmail[1]
|
||||||
|
configFile.Configs[IndexServerAddress()] = authConfig
|
||||||
|
} else {
|
||||||
|
for k, authConfig := range configFile.Configs {
|
||||||
|
authConfig.Username, authConfig.Password, err = decodeAuth(authConfig.Auth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
authConfig.Auth = ""
|
||||||
|
configFile.Configs[k] = authConfig
|
||||||
|
}
|
||||||
}
|
}
|
||||||
origAuth := strings.Split(arr[0], " = ")
|
return &configFile, nil
|
||||||
origEmail := strings.Split(arr[1], " = ")
|
|
||||||
authConfig, err := decodeAuth(origAuth[1])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
authConfig.Email = origEmail[1]
|
|
||||||
authConfig.rootPath = rootPath
|
|
||||||
return authConfig, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the auth config
|
// save the auth config
|
||||||
func SaveConfig(authConfig *AuthConfig) error {
|
func SaveConfig(configFile *ConfigFile) error {
|
||||||
confFile := path.Join(authConfig.rootPath, CONFIGFILE)
|
confFile := path.Join(configFile.rootPath, CONFIGFILE)
|
||||||
if len(authConfig.Email) == 0 {
|
if len(configFile.Configs) == 0 {
|
||||||
os.Remove(confFile)
|
os.Remove(confFile)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
lines := "auth = " + encodeAuth(authConfig) + "\n" + "email = " + authConfig.Email + "\n"
|
|
||||||
b := []byte(lines)
|
configs := make(map[string]AuthConfig, len(configFile.Configs))
|
||||||
err := ioutil.WriteFile(confFile, b, 0600)
|
for k, authConfig := range configFile.Configs {
|
||||||
|
authCopy := authConfig
|
||||||
|
|
||||||
|
authCopy.Auth = encodeAuth(&authCopy)
|
||||||
|
authCopy.Username = ""
|
||||||
|
authCopy.Password = ""
|
||||||
|
|
||||||
|
configs[k] = authCopy
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := json.Marshal(configs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = ioutil.WriteFile(confFile, b, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -120,8 +140,7 @@ func SaveConfig(authConfig *AuthConfig) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try to register/login to the registry server
|
// try to register/login to the registry server
|
||||||
func Login(authConfig *AuthConfig, store bool) (string, error) {
|
func Login(authConfig *AuthConfig) (string, error) {
|
||||||
storeConfig := false
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
reqStatusCode := 0
|
reqStatusCode := 0
|
||||||
var status string
|
var status string
|
||||||
@@ -133,7 +152,7 @@ func Login(authConfig *AuthConfig, store bool) (string, error) {
|
|||||||
|
|
||||||
// using `bytes.NewReader(jsonBody)` here causes the server to respond with a 411 status.
|
// using `bytes.NewReader(jsonBody)` here causes the server to respond with a 411 status.
|
||||||
b := strings.NewReader(string(jsonBody))
|
b := strings.NewReader(string(jsonBody))
|
||||||
req1, err := http.Post(IndexServerAddress()+"/users/", "application/json; charset=utf-8", b)
|
req1, err := http.Post(IndexServerAddress()+"users/", "application/json; charset=utf-8", b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Server Error: %s", err)
|
return "", fmt.Errorf("Server Error: %s", err)
|
||||||
}
|
}
|
||||||
@@ -146,14 +165,13 @@ func Login(authConfig *AuthConfig, store bool) (string, error) {
|
|||||||
|
|
||||||
if reqStatusCode == 201 {
|
if reqStatusCode == 201 {
|
||||||
status = "Account created. Please use the confirmation link we sent" +
|
status = "Account created. Please use the confirmation link we sent" +
|
||||||
" to your e-mail to activate it.\n"
|
" to your e-mail to activate it."
|
||||||
storeConfig = true
|
|
||||||
} else if reqStatusCode == 403 {
|
} else if reqStatusCode == 403 {
|
||||||
return "", fmt.Errorf("Login: Your account hasn't been activated. " +
|
return "", fmt.Errorf("Login: Your account hasn't been activated. " +
|
||||||
"Please check your e-mail for a confirmation link.")
|
"Please check your e-mail for a confirmation link.")
|
||||||
} else if reqStatusCode == 400 {
|
} else if reqStatusCode == 400 {
|
||||||
if string(reqBody) == "\"Username or email already exists\"" {
|
if string(reqBody) == "\"Username or email already exists\"" {
|
||||||
req, err := http.NewRequest("GET", IndexServerAddress()+"/users/", nil)
|
req, err := http.NewRequest("GET", IndexServerAddress()+"users/", nil)
|
||||||
req.SetBasicAuth(authConfig.Username, authConfig.Password)
|
req.SetBasicAuth(authConfig.Username, authConfig.Password)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -165,14 +183,8 @@ func Login(authConfig *AuthConfig, store bool) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if resp.StatusCode == 200 {
|
if resp.StatusCode == 200 {
|
||||||
status = "Login Succeeded\n"
|
status = "Login Succeeded"
|
||||||
storeConfig = true
|
|
||||||
} else if resp.StatusCode == 401 {
|
} else if resp.StatusCode == 401 {
|
||||||
if store {
|
|
||||||
if err := SaveConfig(authConfig); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", fmt.Errorf("Wrong login/password, please try again")
|
return "", fmt.Errorf("Wrong login/password, please try again")
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body,
|
return "", fmt.Errorf("Login: %s (Code: %d; Headers: %s)", body,
|
||||||
@@ -184,10 +196,5 @@ func Login(authConfig *AuthConfig, store bool) (string, error) {
|
|||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("Unexpected status code [%d] : %s", reqStatusCode, reqBody)
|
return "", fmt.Errorf("Unexpected status code [%d] : %s", reqStatusCode, reqBody)
|
||||||
}
|
}
|
||||||
if storeConfig && store {
|
|
||||||
if err := SaveConfig(authConfig); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package auth
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -10,8 +11,10 @@ import (
|
|||||||
|
|
||||||
func TestEncodeAuth(t *testing.T) {
|
func TestEncodeAuth(t *testing.T) {
|
||||||
newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"}
|
newAuthConfig := &AuthConfig{Username: "ken", Password: "test", Email: "test@example.com"}
|
||||||
authStr := EncodeAuth(newAuthConfig)
|
authStr := encodeAuth(newAuthConfig)
|
||||||
decAuthConfig, err := DecodeAuth(authStr)
|
decAuthConfig := &AuthConfig{}
|
||||||
|
var err error
|
||||||
|
decAuthConfig.Username, decAuthConfig.Password, err = decodeAuth(authStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -29,12 +32,12 @@ func TestEncodeAuth(t *testing.T) {
|
|||||||
func TestLogin(t *testing.T) {
|
func TestLogin(t *testing.T) {
|
||||||
os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com")
|
os.Setenv("DOCKER_INDEX_URL", "https://indexstaging-docker.dotcloud.com")
|
||||||
defer os.Setenv("DOCKER_INDEX_URL", "")
|
defer os.Setenv("DOCKER_INDEX_URL", "")
|
||||||
authConfig := NewAuthConfig("unittester", "surlautrerivejetattendrai", "noise+unittester@dotcloud.com", "/tmp")
|
authConfig := &AuthConfig{Username: "unittester", Password: "surlautrerivejetattendrai", Email: "noise+unittester@dotcloud.com"}
|
||||||
status, err := Login(authConfig)
|
status, err := Login(authConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if status != "Login Succeeded\n" {
|
if status != "Login Succeeded" {
|
||||||
t.Fatalf("Expected status \"Login Succeeded\", found \"%s\" instead", status)
|
t.Fatalf("Expected status \"Login Succeeded\", found \"%s\" instead", status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,13 +52,13 @@ func TestCreateAccount(t *testing.T) {
|
|||||||
}
|
}
|
||||||
token := hex.EncodeToString(tokenBuffer)[:12]
|
token := hex.EncodeToString(tokenBuffer)[:12]
|
||||||
username := "ut" + token
|
username := "ut" + token
|
||||||
authConfig := NewAuthConfig(username, "test42", "docker-ut+"+token+"@example.com", "/tmp")
|
authConfig := &AuthConfig{Username: username, Password: "test42", Email: "docker-ut+" + token + "@example.com"}
|
||||||
status, err := Login(authConfig)
|
status, err := Login(authConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
expectedStatus := "Account created. Please use the confirmation link we sent" +
|
expectedStatus := "Account created. Please use the confirmation link we sent" +
|
||||||
" to your e-mail to activate it.\n"
|
" to your e-mail to activate it."
|
||||||
if status != expectedStatus {
|
if status != expectedStatus {
|
||||||
t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status)
|
t.Fatalf("Expected status: \"%s\", found \"%s\" instead.", expectedStatus, status)
|
||||||
}
|
}
|
||||||
@@ -68,6 +71,42 @@ func TestCreateAccount(t *testing.T) {
|
|||||||
expectedError := "Login: Account is not Active"
|
expectedError := "Login: Account is not Active"
|
||||||
|
|
||||||
if !strings.Contains(err.Error(), expectedError) {
|
if !strings.Contains(err.Error(), expectedError) {
|
||||||
t.Fatalf("Expected message \"%s\" but found \"%s\" instead", expectedError, err.Error())
|
t.Fatalf("Expected message \"%s\" but found \"%s\" instead", expectedError, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSameAuthDataPostSave(t *testing.T) {
|
||||||
|
root, err := ioutil.TempDir("", "docker-test")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
configFile := &ConfigFile{
|
||||||
|
rootPath: root,
|
||||||
|
Configs: make(map[string]AuthConfig, 1),
|
||||||
|
}
|
||||||
|
|
||||||
|
configFile.Configs["testIndex"] = AuthConfig{
|
||||||
|
Username: "docker-user",
|
||||||
|
Password: "docker-pass",
|
||||||
|
Email: "docker@docker.io",
|
||||||
|
}
|
||||||
|
|
||||||
|
err = SaveConfig(configFile)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
authConfig := configFile.Configs["testIndex"]
|
||||||
|
if authConfig.Username != "docker-user" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
if authConfig.Password != "docker-pass" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
if authConfig.Email != "docker@docker.io" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
if authConfig.Auth != "" {
|
||||||
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,12 +50,23 @@ func (builder *Builder) Create(config *Config) (*Container, error) {
|
|||||||
config.Hostname = id[:12]
|
config.Hostname = id[:12]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var args []string
|
||||||
|
var entrypoint string
|
||||||
|
|
||||||
|
if len(config.Entrypoint) != 0 {
|
||||||
|
entrypoint = config.Entrypoint[0]
|
||||||
|
args = append(config.Entrypoint[1:], config.Cmd...)
|
||||||
|
} else {
|
||||||
|
entrypoint = config.Cmd[0]
|
||||||
|
args = config.Cmd[1:]
|
||||||
|
}
|
||||||
|
|
||||||
container := &Container{
|
container := &Container{
|
||||||
// FIXME: we should generate the ID here instead of receiving it as an argument
|
// FIXME: we should generate the ID here instead of receiving it as an argument
|
||||||
ID: id,
|
ID: id,
|
||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
Path: config.Cmd[0],
|
Path: entrypoint,
|
||||||
Args: config.Cmd[1:], //FIXME: de-duplicate from config
|
Args: args, //FIXME: de-duplicate from config
|
||||||
Config: config,
|
Config: config,
|
||||||
Image: img.ID, // Always use the resolved image id
|
Image: img.ID, // Always use the resolved image id
|
||||||
NetworkSettings: &NetworkSettings{},
|
NetworkSettings: &NetworkSettings{},
|
||||||
@@ -113,6 +124,10 @@ func (builder *Builder) Create(config *Config) (*Container, error) {
|
|||||||
func (builder *Builder) Commit(container *Container, repository, tag, comment, author string, config *Config) (*Image, error) {
|
func (builder *Builder) Commit(container *Container, repository, tag, comment, author string, config *Config) (*Image, error) {
|
||||||
// FIXME: freeze the container before copying it to avoid data corruption?
|
// FIXME: freeze the container before copying it to avoid data corruption?
|
||||||
// FIXME: this shouldn't be in commands.
|
// FIXME: this shouldn't be in commands.
|
||||||
|
if err := container.EnsureMounted(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
rwTar, err := container.ExportRw()
|
rwTar, err := container.ExportRw()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -1,314 +0,0 @@
|
|||||||
package docker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"github.com/dotcloud/docker/utils"
|
|
||||||
"io"
|
|
||||||
"net/url"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type builderClient struct {
|
|
||||||
cli *DockerCli
|
|
||||||
|
|
||||||
image string
|
|
||||||
maintainer string
|
|
||||||
config *Config
|
|
||||||
|
|
||||||
tmpContainers map[string]struct{}
|
|
||||||
tmpImages map[string]struct{}
|
|
||||||
|
|
||||||
needCommit bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) clearTmp(containers, images map[string]struct{}) {
|
|
||||||
for i := range images {
|
|
||||||
if _, _, err := b.cli.call("DELETE", "/images/"+i, nil); err != nil {
|
|
||||||
utils.Debugf("%s", err)
|
|
||||||
}
|
|
||||||
utils.Debugf("Removing image %s", i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdFrom(name string) error {
|
|
||||||
obj, statusCode, err := b.cli.call("GET", "/images/"+name+"/json", nil)
|
|
||||||
if statusCode == 404 {
|
|
||||||
|
|
||||||
remote := name
|
|
||||||
var tag string
|
|
||||||
if strings.Contains(remote, ":") {
|
|
||||||
remoteParts := strings.Split(remote, ":")
|
|
||||||
tag = remoteParts[1]
|
|
||||||
remote = remoteParts[0]
|
|
||||||
}
|
|
||||||
var out io.Writer
|
|
||||||
if os.Getenv("DEBUG") != "" {
|
|
||||||
out = os.Stdout
|
|
||||||
} else {
|
|
||||||
out = &utils.NopWriter{}
|
|
||||||
}
|
|
||||||
if err := b.cli.stream("POST", "/images/create?fromImage="+remote+"&tag="+tag, nil, out); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
obj, _, err = b.cli.call("GET", "/images/"+name+"/json", nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
img := &APIID{}
|
|
||||||
if err := json.Unmarshal(obj, img); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b.image = img.ID
|
|
||||||
utils.Debugf("Using image %s", b.image)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdMaintainer(name string) error {
|
|
||||||
b.needCommit = true
|
|
||||||
b.maintainer = name
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdRun(args string) error {
|
|
||||||
if b.image == "" {
|
|
||||||
return fmt.Errorf("Please provide a source image with `from` prior to run")
|
|
||||||
}
|
|
||||||
config, _, err := ParseRun([]string{b.image, "/bin/sh", "-c", args}, nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd, env := b.config.Cmd, b.config.Env
|
|
||||||
b.config.Cmd = nil
|
|
||||||
MergeConfig(b.config, config)
|
|
||||||
|
|
||||||
body, statusCode, err := b.cli.call("POST", "/images/getCache", &APIImageConfig{ID: b.image, Config: b.config})
|
|
||||||
if err != nil {
|
|
||||||
if statusCode != 404 {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if statusCode != 404 {
|
|
||||||
apiID := &APIID{}
|
|
||||||
if err := json.Unmarshal(body, apiID); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
utils.Debugf("Use cached version")
|
|
||||||
b.image = apiID.ID
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
cid, err := b.run()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b.config.Cmd, b.config.Env = cmd, env
|
|
||||||
return b.commit(cid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdEnv(args string) error {
|
|
||||||
b.needCommit = true
|
|
||||||
tmp := strings.SplitN(args, " ", 2)
|
|
||||||
if len(tmp) != 2 {
|
|
||||||
return fmt.Errorf("Invalid ENV format")
|
|
||||||
}
|
|
||||||
key := strings.Trim(tmp[0], " ")
|
|
||||||
value := strings.Trim(tmp[1], " ")
|
|
||||||
|
|
||||||
for i, elem := range b.config.Env {
|
|
||||||
if strings.HasPrefix(elem, key+"=") {
|
|
||||||
b.config.Env[i] = key + "=" + value
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.config.Env = append(b.config.Env, key+"="+value)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdCmd(args string) error {
|
|
||||||
b.needCommit = true
|
|
||||||
var cmd []string
|
|
||||||
if err := json.Unmarshal([]byte(args), &cmd); err != nil {
|
|
||||||
utils.Debugf("Error unmarshalling: %s, using /bin/sh -c", err)
|
|
||||||
b.config.Cmd = []string{"/bin/sh", "-c", args}
|
|
||||||
} else {
|
|
||||||
b.config.Cmd = cmd
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdExpose(args string) error {
|
|
||||||
ports := strings.Split(args, " ")
|
|
||||||
b.config.PortSpecs = append(ports, b.config.PortSpecs...)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) CmdInsert(args string) error {
|
|
||||||
// tmp := strings.SplitN(args, "\t ", 2)
|
|
||||||
// sourceUrl, destPath := tmp[0], tmp[1]
|
|
||||||
|
|
||||||
// v := url.Values{}
|
|
||||||
// v.Set("url", sourceUrl)
|
|
||||||
// v.Set("path", destPath)
|
|
||||||
// body, _, err := b.cli.call("POST", "/images/insert?"+v.Encode(), nil)
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// apiId := &APIId{}
|
|
||||||
// if err := json.Unmarshal(body, apiId); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// FIXME: Reimplement this, we need to retrieve the resulting Id
|
|
||||||
return fmt.Errorf("INSERT not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) run() (string, error) {
|
|
||||||
if b.image == "" {
|
|
||||||
return "", fmt.Errorf("Please provide a source image with `from` prior to run")
|
|
||||||
}
|
|
||||||
b.config.Image = b.image
|
|
||||||
body, _, err := b.cli.call("POST", "/containers/create", b.config)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
apiRun := &APIRun{}
|
|
||||||
if err := json.Unmarshal(body, apiRun); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
for _, warning := range apiRun.Warnings {
|
|
||||||
fmt.Fprintln(os.Stderr, "WARNING: ", warning)
|
|
||||||
}
|
|
||||||
|
|
||||||
//start the container
|
|
||||||
_, _, err = b.cli.call("POST", "/containers/"+apiRun.ID+"/start", nil)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
b.tmpContainers[apiRun.ID] = struct{}{}
|
|
||||||
|
|
||||||
// Wait for it to finish
|
|
||||||
body, _, err = b.cli.call("POST", "/containers/"+apiRun.ID+"/wait", nil)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
apiWait := &APIWait{}
|
|
||||||
if err := json.Unmarshal(body, apiWait); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if apiWait.StatusCode != 0 {
|
|
||||||
return "", fmt.Errorf("The command %v returned a non-zero code: %d", b.config.Cmd, apiWait.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
return apiRun.ID, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) commit(id string) error {
|
|
||||||
if b.image == "" {
|
|
||||||
return fmt.Errorf("Please provide a source image with `from` prior to run")
|
|
||||||
}
|
|
||||||
b.config.Image = b.image
|
|
||||||
|
|
||||||
if id == "" {
|
|
||||||
cmd := b.config.Cmd
|
|
||||||
b.config.Cmd = []string{"true"}
|
|
||||||
cid, err := b.run()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
id = cid
|
|
||||||
b.config.Cmd = cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit the container
|
|
||||||
v := url.Values{}
|
|
||||||
v.Set("container", id)
|
|
||||||
v.Set("author", b.maintainer)
|
|
||||||
|
|
||||||
body, _, err := b.cli.call("POST", "/commit?"+v.Encode(), b.config)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
apiID := &APIID{}
|
|
||||||
if err := json.Unmarshal(body, apiID); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b.tmpImages[apiID.ID] = struct{}{}
|
|
||||||
b.image = apiID.ID
|
|
||||||
b.needCommit = false
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *builderClient) Build(dockerfile, context io.Reader) (string, error) {
|
|
||||||
defer b.clearTmp(b.tmpContainers, b.tmpImages)
|
|
||||||
file := bufio.NewReader(dockerfile)
|
|
||||||
for {
|
|
||||||
line, err := file.ReadString('\n')
|
|
||||||
if err != nil {
|
|
||||||
if err == io.EOF {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
line = strings.Replace(strings.TrimSpace(line), " ", " ", 1)
|
|
||||||
// Skip comments and empty line
|
|
||||||
if len(line) == 0 || line[0] == '#' {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
tmp := strings.SplitN(line, " ", 2)
|
|
||||||
if len(tmp) != 2 {
|
|
||||||
return "", fmt.Errorf("Invalid Dockerfile format")
|
|
||||||
}
|
|
||||||
instruction := strings.ToLower(strings.Trim(tmp[0], " "))
|
|
||||||
arguments := strings.Trim(tmp[1], " ")
|
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "%s %s (%s)\n", strings.ToUpper(instruction), arguments, b.image)
|
|
||||||
|
|
||||||
method, exists := reflect.TypeOf(b).MethodByName("Cmd" + strings.ToUpper(instruction[:1]) + strings.ToLower(instruction[1:]))
|
|
||||||
if !exists {
|
|
||||||
fmt.Fprintf(os.Stderr, "Skipping unknown instruction %s\n", strings.ToUpper(instruction))
|
|
||||||
}
|
|
||||||
ret := method.Func.Call([]reflect.Value{reflect.ValueOf(b), reflect.ValueOf(arguments)})[0].Interface()
|
|
||||||
if ret != nil {
|
|
||||||
return "", ret.(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "===> %v\n", b.image)
|
|
||||||
}
|
|
||||||
if b.needCommit {
|
|
||||||
if err := b.commit(""); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if b.image != "" {
|
|
||||||
// The build is successful, keep the temporary containers and images
|
|
||||||
for i := range b.tmpImages {
|
|
||||||
delete(b.tmpImages, i)
|
|
||||||
}
|
|
||||||
for i := range b.tmpContainers {
|
|
||||||
delete(b.tmpContainers, i)
|
|
||||||
}
|
|
||||||
fmt.Fprintf(os.Stderr, "Build finished. image id: %s\n", b.image)
|
|
||||||
return b.image, nil
|
|
||||||
}
|
|
||||||
return "", fmt.Errorf("An error occured during the build\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewBuilderClient(addr string, port int) BuildFile {
|
|
||||||
return &builderClient{
|
|
||||||
cli: NewDockerCli(addr, port),
|
|
||||||
config: &Config{},
|
|
||||||
tmpContainers: make(map[string]struct{}),
|
|
||||||
tmpImages: make(map[string]struct{}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,14 +7,16 @@ import (
|
|||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BuildFile interface {
|
type BuildFile interface {
|
||||||
Build(io.Reader, io.Reader) (string, error)
|
Build(io.Reader) (string, error)
|
||||||
CmdFrom(string) error
|
CmdFrom(string) error
|
||||||
CmdRun(string) error
|
CmdRun(string) error
|
||||||
}
|
}
|
||||||
@@ -28,6 +30,7 @@ type buildFile struct {
|
|||||||
maintainer string
|
maintainer string
|
||||||
config *Config
|
config *Config
|
||||||
context string
|
context string
|
||||||
|
verbose bool
|
||||||
|
|
||||||
tmpContainers map[string]struct{}
|
tmpContainers map[string]struct{}
|
||||||
tmpImages map[string]struct{}
|
tmpImages map[string]struct{}
|
||||||
@@ -51,20 +54,10 @@ func (b *buildFile) CmdFrom(name string) error {
|
|||||||
image, err := b.runtime.repositories.LookupImage(name)
|
image, err := b.runtime.repositories.LookupImage(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if b.runtime.graph.IsNotExist(err) {
|
if b.runtime.graph.IsNotExist(err) {
|
||||||
|
remote, tag := utils.ParseRepositoryTag(name)
|
||||||
var tag, remote string
|
if err := b.srv.ImagePull(remote, tag, b.out, utils.NewStreamFormatter(false), nil); err != nil {
|
||||||
if strings.Contains(name, ":") {
|
|
||||||
remoteParts := strings.Split(name, ":")
|
|
||||||
tag = remoteParts[1]
|
|
||||||
remote = remoteParts[0]
|
|
||||||
} else {
|
|
||||||
remote = name
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := b.srv.ImagePull(remote, tag, "", b.out, utils.NewStreamFormatter(false), nil); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err = b.runtime.repositories.LookupImage(name)
|
image, err = b.runtime.repositories.LookupImage(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -75,6 +68,9 @@ func (b *buildFile) CmdFrom(name string) error {
|
|||||||
}
|
}
|
||||||
b.image = image.ID
|
b.image = image.ID
|
||||||
b.config = &Config{}
|
b.config = &Config{}
|
||||||
|
if b.config.Env == nil || len(b.config.Env) == 0 {
|
||||||
|
b.config.Env = append(b.config.Env, "HOME=/", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +83,7 @@ func (b *buildFile) CmdRun(args string) error {
|
|||||||
if b.image == "" {
|
if b.image == "" {
|
||||||
return fmt.Errorf("Please provide a source image with `from` prior to run")
|
return fmt.Errorf("Please provide a source image with `from` prior to run")
|
||||||
}
|
}
|
||||||
config, _, err := ParseRun([]string{b.image, "/bin/sh", "-c", args}, nil)
|
config, _, _, err := ParseRun([]string{b.image, "/bin/sh", "-c", args}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -101,6 +97,7 @@ func (b *buildFile) CmdRun(args string) error {
|
|||||||
if cache, err := b.srv.ImageGetCached(b.image, b.config); err != nil {
|
if cache, err := b.srv.ImageGetCached(b.image, b.config); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if cache != nil {
|
} else if cache != nil {
|
||||||
|
fmt.Fprintf(b.out, " ---> Using cache\n")
|
||||||
utils.Debugf("[BUILDER] Use cached version")
|
utils.Debugf("[BUILDER] Use cached version")
|
||||||
b.image = cache.ID
|
b.image = cache.ID
|
||||||
return nil
|
return nil
|
||||||
@@ -119,28 +116,67 @@ func (b *buildFile) CmdRun(args string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *buildFile) FindEnvKey(key string) int {
|
||||||
|
for k, envVar := range b.config.Env {
|
||||||
|
envParts := strings.SplitN(envVar, "=", 2)
|
||||||
|
if key == envParts[0] {
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *buildFile) ReplaceEnvMatches(value string) (string, error) {
|
||||||
|
exp, err := regexp.Compile("(\\\\\\\\+|[^\\\\]|\\b|\\A)\\$({?)([[:alnum:]_]+)(}?)")
|
||||||
|
if err != nil {
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
matches := exp.FindAllString(value, -1)
|
||||||
|
for _, match := range matches {
|
||||||
|
match = match[strings.Index(match, "$"):]
|
||||||
|
matchKey := strings.Trim(match, "${}")
|
||||||
|
|
||||||
|
for _, envVar := range b.config.Env {
|
||||||
|
envParts := strings.SplitN(envVar, "=", 2)
|
||||||
|
envKey := envParts[0]
|
||||||
|
envValue := envParts[1]
|
||||||
|
|
||||||
|
if envKey == matchKey {
|
||||||
|
value = strings.Replace(value, match, envValue, -1)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b *buildFile) CmdEnv(args string) error {
|
func (b *buildFile) CmdEnv(args string) error {
|
||||||
tmp := strings.SplitN(args, " ", 2)
|
tmp := strings.SplitN(args, " ", 2)
|
||||||
if len(tmp) != 2 {
|
if len(tmp) != 2 {
|
||||||
return fmt.Errorf("Invalid ENV format")
|
return fmt.Errorf("Invalid ENV format")
|
||||||
}
|
}
|
||||||
key := strings.Trim(tmp[0], " ")
|
key := strings.Trim(tmp[0], " \t")
|
||||||
value := strings.Trim(tmp[1], " ")
|
value := strings.Trim(tmp[1], " \t")
|
||||||
|
|
||||||
for i, elem := range b.config.Env {
|
envKey := b.FindEnvKey(key)
|
||||||
if strings.HasPrefix(elem, key+"=") {
|
replacedValue, err := b.ReplaceEnvMatches(value)
|
||||||
b.config.Env[i] = key + "=" + value
|
if err != nil {
|
||||||
return nil
|
return err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
b.config.Env = append(b.config.Env, key+"="+value)
|
replacedVar := fmt.Sprintf("%s=%s", key, replacedValue)
|
||||||
return b.commit("", b.config.Cmd, fmt.Sprintf("ENV %s=%s", key, value))
|
|
||||||
|
if envKey >= 0 {
|
||||||
|
b.config.Env[envKey] = replacedVar
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
b.config.Env = append(b.config.Env, replacedVar)
|
||||||
|
return b.commit("", b.config.Cmd, fmt.Sprintf("ENV %s", replacedVar))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *buildFile) CmdCmd(args string) error {
|
func (b *buildFile) CmdCmd(args string) error {
|
||||||
var cmd []string
|
var cmd []string
|
||||||
if err := json.Unmarshal([]byte(args), &cmd); err != nil {
|
if err := json.Unmarshal([]byte(args), &cmd); err != nil {
|
||||||
utils.Debugf("Error unmarshalling: %s, using /bin/sh -c", err)
|
utils.Debugf("Error unmarshalling: %s, setting cmd to /bin/sh -c", err)
|
||||||
cmd = []string{"/bin/sh", "-c", args}
|
cmd = []string{"/bin/sh", "-c", args}
|
||||||
}
|
}
|
||||||
if err := b.commit("", cmd, fmt.Sprintf("CMD %v", cmd)); err != nil {
|
if err := b.commit("", cmd, fmt.Sprintf("CMD %v", cmd)); err != nil {
|
||||||
@@ -164,6 +200,104 @@ func (b *buildFile) CmdCopy(args string) error {
|
|||||||
return fmt.Errorf("COPY has been deprecated. Please use ADD instead")
|
return fmt.Errorf("COPY has been deprecated. Please use ADD instead")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *buildFile) CmdEntrypoint(args string) error {
|
||||||
|
if args == "" {
|
||||||
|
return fmt.Errorf("Entrypoint cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
var entrypoint []string
|
||||||
|
if err := json.Unmarshal([]byte(args), &entrypoint); err != nil {
|
||||||
|
b.config.Entrypoint = []string{"/bin/sh", "-c", args}
|
||||||
|
} else {
|
||||||
|
b.config.Entrypoint = entrypoint
|
||||||
|
}
|
||||||
|
if err := b.commit("", b.config.Cmd, fmt.Sprintf("ENTRYPOINT %s", args)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *buildFile) CmdVolume(args string) error {
|
||||||
|
if args == "" {
|
||||||
|
return fmt.Errorf("Volume cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
var volume []string
|
||||||
|
if err := json.Unmarshal([]byte(args), &volume); err != nil {
|
||||||
|
volume = []string{args}
|
||||||
|
}
|
||||||
|
if b.config.Volumes == nil {
|
||||||
|
b.config.Volumes = NewPathOpts()
|
||||||
|
}
|
||||||
|
for _, v := range volume {
|
||||||
|
b.config.Volumes[v] = struct{}{}
|
||||||
|
}
|
||||||
|
if err := b.commit("", b.config.Cmd, fmt.Sprintf("VOLUME %s", args)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *buildFile) addRemote(container *Container, orig, dest string) error {
|
||||||
|
file, err := utils.Download(orig, ioutil.Discard)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Body.Close()
|
||||||
|
|
||||||
|
// If the destination is a directory, figure out the filename.
|
||||||
|
if strings.HasSuffix(dest, "/") {
|
||||||
|
u, err := url.Parse(orig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
path := u.Path
|
||||||
|
if strings.HasSuffix(path, "/") {
|
||||||
|
path = path[:len(path)-1]
|
||||||
|
}
|
||||||
|
parts := strings.Split(path, "/")
|
||||||
|
filename := parts[len(parts)-1]
|
||||||
|
if filename == "" {
|
||||||
|
return fmt.Errorf("cannot determine filename from url: %s", u)
|
||||||
|
}
|
||||||
|
dest = dest + filename
|
||||||
|
}
|
||||||
|
|
||||||
|
return container.Inject(file.Body, dest)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *buildFile) addContext(container *Container, orig, dest string) error {
|
||||||
|
origPath := path.Join(b.context, orig)
|
||||||
|
destPath := path.Join(container.RootfsPath(), dest)
|
||||||
|
// Preserve the trailing '/'
|
||||||
|
if strings.HasSuffix(dest, "/") {
|
||||||
|
destPath = destPath + "/"
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(origPath, b.context) {
|
||||||
|
return fmt.Errorf("Forbidden path: %s", origPath)
|
||||||
|
}
|
||||||
|
fi, err := os.Stat(origPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if fi.IsDir() {
|
||||||
|
if err := CopyWithTar(origPath, destPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// First try to unpack the source as an archive
|
||||||
|
} else if err := UntarPath(origPath, destPath); err != nil {
|
||||||
|
utils.Debugf("Couldn't untar %s to %s: %s", origPath, destPath, err)
|
||||||
|
// If that fails, just copy it as a regular file
|
||||||
|
if err := os.MkdirAll(path.Dir(destPath), 0755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := CopyWithTar(origPath, destPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b *buildFile) CmdAdd(args string) error {
|
func (b *buildFile) CmdAdd(args string) error {
|
||||||
if b.context == "" {
|
if b.context == "" {
|
||||||
return fmt.Errorf("No context given. Impossible to use ADD")
|
return fmt.Errorf("No context given. Impossible to use ADD")
|
||||||
@@ -172,14 +306,22 @@ func (b *buildFile) CmdAdd(args string) error {
|
|||||||
if len(tmp) != 2 {
|
if len(tmp) != 2 {
|
||||||
return fmt.Errorf("Invalid ADD format")
|
return fmt.Errorf("Invalid ADD format")
|
||||||
}
|
}
|
||||||
orig := strings.Trim(tmp[0], " ")
|
|
||||||
dest := strings.Trim(tmp[1], " ")
|
orig, err := b.ReplaceEnvMatches(strings.Trim(tmp[0], " \t"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
dest, err := b.ReplaceEnvMatches(strings.Trim(tmp[1], " \t"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
cmd := b.config.Cmd
|
cmd := b.config.Cmd
|
||||||
|
|
||||||
// Create the container and start it
|
|
||||||
b.config.Cmd = []string{"/bin/sh", "-c", fmt.Sprintf("#(nop) ADD %s in %s", orig, dest)}
|
b.config.Cmd = []string{"/bin/sh", "-c", fmt.Sprintf("#(nop) ADD %s in %s", orig, dest)}
|
||||||
|
|
||||||
b.config.Image = b.image
|
b.config.Image = b.image
|
||||||
|
// Create the container and start it
|
||||||
container, err := b.builder.Create(b.config)
|
container, err := b.builder.Create(b.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -191,31 +333,16 @@ func (b *buildFile) CmdAdd(args string) error {
|
|||||||
}
|
}
|
||||||
defer container.Unmount()
|
defer container.Unmount()
|
||||||
|
|
||||||
origPath := path.Join(b.context, orig)
|
if utils.IsURL(orig) {
|
||||||
destPath := path.Join(container.RootfsPath(), dest)
|
if err := b.addRemote(container, orig, dest); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := b.addContext(container, orig, dest); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fi, err := os.Stat(origPath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if fi.IsDir() {
|
|
||||||
if err := os.MkdirAll(destPath, 0700); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := CopyWithTar(origPath, destPath); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// First try to unpack the source as an archive
|
|
||||||
} else if err := UntarPath(origPath, destPath); err != nil {
|
|
||||||
utils.Debugf("Couldn't untar %s to %s: %s", origPath, destPath, err)
|
|
||||||
// If that fails, just copy it as a regular file
|
|
||||||
if err := os.MkdirAll(path.Dir(destPath), 0700); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := CopyWithTar(origPath, destPath); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := b.commit(container.ID, cmd, fmt.Sprintf("ADD %s in %s", orig, dest)); err != nil {
|
if err := b.commit(container.ID, cmd, fmt.Sprintf("ADD %s in %s", orig, dest)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -235,12 +362,25 @@ func (b *buildFile) run() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
b.tmpContainers[c.ID] = struct{}{}
|
b.tmpContainers[c.ID] = struct{}{}
|
||||||
|
fmt.Fprintf(b.out, " ---> Running in %s\n", utils.TruncateID(c.ID))
|
||||||
|
|
||||||
|
// override the entry point that may have been picked up from the base image
|
||||||
|
c.Path = b.config.Cmd[0]
|
||||||
|
c.Args = b.config.Cmd[1:]
|
||||||
|
|
||||||
//start the container
|
//start the container
|
||||||
if err := c.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := c.Start(hostConfig); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if b.verbose {
|
||||||
|
err = <-c.Attach(nil, nil, b.out, b.out)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for it to finish
|
// Wait for it to finish
|
||||||
if ret := c.Wait(); ret != 0 {
|
if ret := c.Wait(); ret != 0 {
|
||||||
return "", fmt.Errorf("The command %v returned a non-zero code: %d", b.config.Cmd, ret)
|
return "", fmt.Errorf("The command %v returned a non-zero code: %d", b.config.Cmd, ret)
|
||||||
@@ -256,31 +396,31 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error {
|
|||||||
}
|
}
|
||||||
b.config.Image = b.image
|
b.config.Image = b.image
|
||||||
if id == "" {
|
if id == "" {
|
||||||
|
cmd := b.config.Cmd
|
||||||
b.config.Cmd = []string{"/bin/sh", "-c", "#(nop) " + comment}
|
b.config.Cmd = []string{"/bin/sh", "-c", "#(nop) " + comment}
|
||||||
|
defer func(cmd []string) { b.config.Cmd = cmd }(cmd)
|
||||||
|
|
||||||
if cache, err := b.srv.ImageGetCached(b.image, b.config); err != nil {
|
if cache, err := b.srv.ImageGetCached(b.image, b.config); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if cache != nil {
|
} else if cache != nil {
|
||||||
|
fmt.Fprintf(b.out, " ---> Using cache\n")
|
||||||
utils.Debugf("[BUILDER] Use cached version")
|
utils.Debugf("[BUILDER] Use cached version")
|
||||||
b.image = cache.ID
|
b.image = cache.ID
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
utils.Debugf("[BUILDER] Cache miss")
|
utils.Debugf("[BUILDER] Cache miss")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the container and start it
|
|
||||||
container, err := b.builder.Create(b.config)
|
container, err := b.builder.Create(b.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
b.tmpContainers[container.ID] = struct{}{}
|
b.tmpContainers[container.ID] = struct{}{}
|
||||||
|
fmt.Fprintf(b.out, " ---> Running in %s\n", utils.TruncateID(container.ID))
|
||||||
|
id = container.ID
|
||||||
if err := container.EnsureMounted(); err != nil {
|
if err := container.EnsureMounted(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer container.Unmount()
|
defer container.Unmount()
|
||||||
|
|
||||||
id = container.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
container := b.runtime.Get(id)
|
container := b.runtime.Get(id)
|
||||||
@@ -301,19 +441,25 @@ func (b *buildFile) commit(id string, autoCmd []string, comment string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
|
func (b *buildFile) Build(context io.Reader) (string, error) {
|
||||||
if context != nil {
|
// FIXME: @creack any reason for using /tmp instead of ""?
|
||||||
name, err := ioutil.TempDir("/tmp", "docker-build")
|
// FIXME: @creack "name" is a terrible variable name
|
||||||
if err != nil {
|
name, err := ioutil.TempDir("/tmp", "docker-build")
|
||||||
return "", err
|
if err != nil {
|
||||||
}
|
return "", err
|
||||||
if err := Untar(context, name); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(name)
|
|
||||||
b.context = name
|
|
||||||
}
|
}
|
||||||
|
if err := Untar(context, name); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(name)
|
||||||
|
b.context = name
|
||||||
|
dockerfile, err := os.Open(path.Join(name, "Dockerfile"))
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("Can't build a directory with no Dockerfile")
|
||||||
|
}
|
||||||
|
// FIXME: "file" is also a terrible variable name ;)
|
||||||
file := bufio.NewReader(dockerfile)
|
file := bufio.NewReader(dockerfile)
|
||||||
|
stepN := 0
|
||||||
for {
|
for {
|
||||||
line, err := file.ReadString('\n')
|
line, err := file.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -323,7 +469,7 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line = strings.Replace(strings.TrimSpace(line), " ", " ", 1)
|
line = strings.Trim(strings.Replace(line, "\t", " ", -1), " \t\r\n")
|
||||||
// Skip comments and empty line
|
// Skip comments and empty line
|
||||||
if len(line) == 0 || line[0] == '#' {
|
if len(line) == 0 || line[0] == '#' {
|
||||||
continue
|
continue
|
||||||
@@ -334,12 +480,13 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
|
|||||||
}
|
}
|
||||||
instruction := strings.ToLower(strings.Trim(tmp[0], " "))
|
instruction := strings.ToLower(strings.Trim(tmp[0], " "))
|
||||||
arguments := strings.Trim(tmp[1], " ")
|
arguments := strings.Trim(tmp[1], " ")
|
||||||
|
stepN += 1
|
||||||
fmt.Fprintf(b.out, "%s %s (%s)\n", strings.ToUpper(instruction), arguments, b.image)
|
// FIXME: only count known instructions as build steps
|
||||||
|
fmt.Fprintf(b.out, "Step %d : %s %s\n", stepN, strings.ToUpper(instruction), arguments)
|
||||||
|
|
||||||
method, exists := reflect.TypeOf(b).MethodByName("Cmd" + strings.ToUpper(instruction[:1]) + strings.ToLower(instruction[1:]))
|
method, exists := reflect.TypeOf(b).MethodByName("Cmd" + strings.ToUpper(instruction[:1]) + strings.ToLower(instruction[1:]))
|
||||||
if !exists {
|
if !exists {
|
||||||
fmt.Fprintf(b.out, "Skipping unknown instruction %s\n", strings.ToUpper(instruction))
|
fmt.Fprintf(b.out, "# Skipping unknown instruction %s\n", strings.ToUpper(instruction))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ret := method.Func.Call([]reflect.Value{reflect.ValueOf(b), reflect.ValueOf(arguments)})[0].Interface()
|
ret := method.Func.Call([]reflect.Value{reflect.ValueOf(b), reflect.ValueOf(arguments)})[0].Interface()
|
||||||
@@ -347,16 +494,16 @@ func (b *buildFile) Build(dockerfile, context io.Reader) (string, error) {
|
|||||||
return "", ret.(error)
|
return "", ret.(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(b.out, "===> %v\n", b.image)
|
fmt.Fprintf(b.out, " ---> %v\n", utils.TruncateID(b.image))
|
||||||
}
|
}
|
||||||
if b.image != "" {
|
if b.image != "" {
|
||||||
fmt.Fprintf(b.out, "Build successful.\n===> %s\n", b.image)
|
fmt.Fprintf(b.out, "Successfully built %s\n", utils.TruncateID(b.image))
|
||||||
return b.image, nil
|
return b.image, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("An error occured during the build\n")
|
return "", fmt.Errorf("An error occured during the build\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBuildFile(srv *Server, out io.Writer) BuildFile {
|
func NewBuildFile(srv *Server, out io.Writer, verbose bool) BuildFile {
|
||||||
return &buildFile{
|
return &buildFile{
|
||||||
builder: NewBuilder(srv.runtime),
|
builder: NewBuilder(srv.runtime),
|
||||||
runtime: srv.runtime,
|
runtime: srv.runtime,
|
||||||
@@ -365,5 +512,6 @@ func NewBuildFile(srv *Server, out io.Writer) BuildFile {
|
|||||||
out: out,
|
out: out,
|
||||||
tmpContainers: make(map[string]struct{}),
|
tmpContainers: make(map[string]struct{}),
|
||||||
tmpImages: make(map[string]struct{}),
|
tmpImages: make(map[string]struct{}),
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,89 +1,376 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/dotcloud/docker/utils"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Dockerfile = `
|
// mkTestContext generates a build context from the contents of the provided dockerfile.
|
||||||
# VERSION 0.1
|
// This context is suitable for use as an argument to BuildFile.Build()
|
||||||
# DOCKER-VERSION 0.2
|
func mkTestContext(dockerfile string, files [][2]string, t *testing.T) Archive {
|
||||||
|
context, err := mkBuildContext(dockerfile, files)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
}
|
||||||
|
|
||||||
from ` + unitTestImageName + `
|
// A testContextTemplate describes a build context and how to test it
|
||||||
|
type testContextTemplate struct {
|
||||||
|
// Contents of the Dockerfile
|
||||||
|
dockerfile string
|
||||||
|
// Additional files in the context, eg [][2]string{"./passwd", "gordon"}
|
||||||
|
files [][2]string
|
||||||
|
// Additional remote files to host on a local HTTP server.
|
||||||
|
remoteFiles [][2]string
|
||||||
|
}
|
||||||
|
|
||||||
|
// A table of all the contexts to build and test.
|
||||||
|
// A new docker runtime will be created and torn down for each context.
|
||||||
|
var testContexts = []testContextTemplate{
|
||||||
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
run sh -c 'echo root:testpass > /tmp/passwd'
|
run sh -c 'echo root:testpass > /tmp/passwd'
|
||||||
run mkdir -p /var/run/sshd
|
run mkdir -p /var/run/sshd
|
||||||
`
|
run [ "$(cat /tmp/passwd)" = "root:testpass" ]
|
||||||
|
run [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
|
||||||
const DockerfileNoNewLine = `
|
{
|
||||||
# VERSION 0.1
|
`
|
||||||
# DOCKER-VERSION 0.2
|
from {IMAGE}
|
||||||
|
add foo /usr/lib/bla/bar
|
||||||
|
run [ "$(cat /usr/lib/bla/bar)" = 'hello' ]
|
||||||
|
add http://{SERVERADDR}/baz /usr/lib/baz/quux
|
||||||
|
run [ "$(cat /usr/lib/baz/quux)" = 'world!' ]
|
||||||
|
`,
|
||||||
|
[][2]string{{"foo", "hello"}},
|
||||||
|
[][2]string{{"/baz", "world!"}},
|
||||||
|
},
|
||||||
|
|
||||||
from ` + unitTestImageName + `
|
{
|
||||||
run sh -c 'echo root:testpass > /tmp/passwd'
|
`
|
||||||
run mkdir -p /var/run/sshd`
|
from {IMAGE}
|
||||||
|
add f /
|
||||||
|
run [ "$(cat /f)" = "hello" ]
|
||||||
|
add f /abc
|
||||||
|
run [ "$(cat /abc)" = "hello" ]
|
||||||
|
add f /x/y/z
|
||||||
|
run [ "$(cat /x/y/z)" = "hello" ]
|
||||||
|
add f /x/y/d/
|
||||||
|
run [ "$(cat /x/y/d/f)" = "hello" ]
|
||||||
|
add d /
|
||||||
|
run [ "$(cat /ga)" = "bu" ]
|
||||||
|
add d /somewhere
|
||||||
|
run [ "$(cat /somewhere/ga)" = "bu" ]
|
||||||
|
add d /anotherplace/
|
||||||
|
run [ "$(cat /anotherplace/ga)" = "bu" ]
|
||||||
|
add d /somewheeeere/over/the/rainbooow
|
||||||
|
run [ "$(cat /somewheeeere/over/the/rainbooow/ga)" = "bu" ]
|
||||||
|
`,
|
||||||
|
[][2]string{
|
||||||
|
{"f", "hello"},
|
||||||
|
{"d/ga", "bu"},
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
|
||||||
// FIXME: test building with a context
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
|
add http://{SERVERADDR}/x /a/b/c
|
||||||
|
run [ "$(cat /a/b/c)" = "hello" ]
|
||||||
|
add http://{SERVERADDR}/x?foo=bar /
|
||||||
|
run [ "$(cat /x)" = "hello" ]
|
||||||
|
add http://{SERVERADDR}/x /d/
|
||||||
|
run [ "$(cat /d/x)" = "hello" ]
|
||||||
|
add http://{SERVERADDR} /e
|
||||||
|
run [ "$(cat /e)" = "blah" ]
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
[][2]string{{"/x", "hello"}, {"/", "blah"}},
|
||||||
|
},
|
||||||
|
|
||||||
// FIXME: test building with a local ADD as first command
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
|
env FOO BAR
|
||||||
|
run [ "$FOO" = "BAR" ]
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
|
ENTRYPOINT /bin/echo
|
||||||
|
CMD Hello world
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
|
VOLUME /test
|
||||||
|
CMD Hello world
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
|
env FOO /foo/baz
|
||||||
|
env BAR /bar
|
||||||
|
env BAZ $BAR
|
||||||
|
env FOOPATH $PATH:$FOO
|
||||||
|
run [ "$BAR" = "$BAZ" ]
|
||||||
|
run [ "$FOOPATH" = "$PATH:/foo/baz" ]
|
||||||
|
`,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
`
|
||||||
|
from {IMAGE}
|
||||||
|
env FOO /bar
|
||||||
|
env TEST testdir
|
||||||
|
env BAZ /foobar
|
||||||
|
add testfile $BAZ/
|
||||||
|
add $TEST $FOO
|
||||||
|
run [ "$(cat /foobar/testfile)" = "test1" ]
|
||||||
|
run [ "$(cat /bar/withfile)" = "test2" ]
|
||||||
|
`,
|
||||||
|
[][2]string{
|
||||||
|
{"testfile", "test1"},
|
||||||
|
{"testdir/withfile", "test2"},
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: test building with 2 successive overlapping ADD commands
|
// FIXME: test building with 2 successive overlapping ADD commands
|
||||||
|
|
||||||
|
func constructDockerfile(template string, ip net.IP, port string) string {
|
||||||
|
serverAddr := fmt.Sprintf("%s:%s", ip, port)
|
||||||
|
replacer := strings.NewReplacer("{IMAGE}", unitTestImageID, "{SERVERADDR}", serverAddr)
|
||||||
|
return replacer.Replace(template)
|
||||||
|
}
|
||||||
|
|
||||||
|
func mkTestingFileServer(files [][2]string) (*httptest.Server, error) {
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
for _, file := range files {
|
||||||
|
name, contents := file[0], file[1]
|
||||||
|
mux.HandleFunc(name, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte(contents))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is how httptest.NewServer sets up a net.Listener, except that our listener must accept remote
|
||||||
|
// connections (from the container).
|
||||||
|
listener, err := net.Listen("tcp", ":0")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
s := httptest.NewUnstartedServer(mux)
|
||||||
|
s.Listener = listener
|
||||||
|
s.Start()
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
func TestBuild(t *testing.T) {
|
func TestBuild(t *testing.T) {
|
||||||
dockerfiles := []string{Dockerfile, DockerfileNoNewLine}
|
for _, ctx := range testContexts {
|
||||||
for _, Dockerfile := range dockerfiles {
|
buildImage(ctx, t)
|
||||||
runtime, err := newTestRuntime()
|
}
|
||||||
if err != nil {
|
}
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
func buildImage(context testContextTemplate, t *testing.T) *Image {
|
||||||
|
runtime, err := newTestRuntime()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
buildfile := NewBuildFile(srv, &utils.NopWriter{})
|
srv := &Server{
|
||||||
|
runtime: runtime,
|
||||||
|
pullingPool: make(map[string]struct{}),
|
||||||
|
pushingPool: make(map[string]struct{}),
|
||||||
|
}
|
||||||
|
|
||||||
imgID, err := buildfile.Build(strings.NewReader(Dockerfile), nil)
|
httpServer, err := mkTestingFileServer(context.remoteFiles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer httpServer.Close()
|
||||||
|
|
||||||
builder := NewBuilder(runtime)
|
idx := strings.LastIndex(httpServer.URL, ":")
|
||||||
container, err := builder.Create(
|
if idx < 0 {
|
||||||
&Config{
|
t.Fatalf("could not get port from test http server address %s", httpServer.URL)
|
||||||
Image: imgID,
|
}
|
||||||
Cmd: []string{"cat", "/tmp/passwd"},
|
port := httpServer.URL[idx+1:]
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container)
|
|
||||||
|
|
||||||
output, err := container.Output()
|
ip := runtime.networkManager.bridgeNetwork.IP
|
||||||
if err != nil {
|
dockerfile := constructDockerfile(context.dockerfile, ip, port)
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if string(output) != "root:testpass\n" {
|
|
||||||
t.Fatalf("Unexpected output. Read '%s', expected '%s'", output, "root:testpass\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
container2, err := builder.Create(
|
buildfile := NewBuildFile(srv, ioutil.Discard, false)
|
||||||
&Config{
|
id, err := buildfile.Build(mkTestContext(dockerfile, context.files, t))
|
||||||
Image: imgID,
|
if err != nil {
|
||||||
Cmd: []string{"ls", "-d", "/var/run/sshd"},
|
t.Fatal(err)
|
||||||
},
|
}
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container2)
|
|
||||||
|
|
||||||
output, err = container2.Output()
|
img, err := srv.ImageInspect(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if string(output) != "/var/run/sshd\n" {
|
return img
|
||||||
t.Fatal("/var/run/sshd has not been created")
|
}
|
||||||
|
|
||||||
|
func TestVolume(t *testing.T) {
|
||||||
|
img := buildImage(testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
volume /test
|
||||||
|
cmd Hello world
|
||||||
|
`, nil, nil}, t)
|
||||||
|
|
||||||
|
if len(img.Config.Volumes) == 0 {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
for key := range img.Config.Volumes {
|
||||||
|
if key != "/test" {
|
||||||
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildMaintainer(t *testing.T) {
|
||||||
|
img := buildImage(testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
maintainer dockerio
|
||||||
|
`, nil, nil}, t)
|
||||||
|
|
||||||
|
if img.Author != "dockerio" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildEnv(t *testing.T) {
|
||||||
|
img := buildImage(testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
env port 4243
|
||||||
|
`,
|
||||||
|
nil, nil}, t)
|
||||||
|
hasEnv := false
|
||||||
|
for _, envVar := range img.Config.Env {
|
||||||
|
if envVar == "port=4243" {
|
||||||
|
hasEnv = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasEnv {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildCmd(t *testing.T) {
|
||||||
|
img := buildImage(testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
cmd ["/bin/echo", "Hello World"]
|
||||||
|
`,
|
||||||
|
nil, nil}, t)
|
||||||
|
|
||||||
|
if img.Config.Cmd[0] != "/bin/echo" {
|
||||||
|
t.Log(img.Config.Cmd[0])
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
if img.Config.Cmd[1] != "Hello World" {
|
||||||
|
t.Log(img.Config.Cmd[1])
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildExpose(t *testing.T) {
|
||||||
|
img := buildImage(testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
expose 4243
|
||||||
|
`,
|
||||||
|
nil, nil}, t)
|
||||||
|
|
||||||
|
if img.Config.PortSpecs[0] != "4243" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBuildEntrypoint(t *testing.T) {
|
||||||
|
img := buildImage(testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
entrypoint ["/bin/echo"]
|
||||||
|
`,
|
||||||
|
nil, nil}, t)
|
||||||
|
|
||||||
|
if img.Config.Entrypoint[0] != "/bin/echo" {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestForbiddenContextPath(t *testing.T) {
|
||||||
|
runtime, err := newTestRuntime()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
srv := &Server{
|
||||||
|
runtime: runtime,
|
||||||
|
pullingPool: make(map[string]struct{}),
|
||||||
|
pushingPool: make(map[string]struct{}),
|
||||||
|
}
|
||||||
|
|
||||||
|
context := testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
maintainer dockerio
|
||||||
|
add ../../ test/
|
||||||
|
`,
|
||||||
|
[][2]string{{"test.txt", "test1"}, {"other.txt", "other"}}, nil}
|
||||||
|
|
||||||
|
httpServer, err := mkTestingFileServer(context.remoteFiles)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer httpServer.Close()
|
||||||
|
|
||||||
|
idx := strings.LastIndex(httpServer.URL, ":")
|
||||||
|
if idx < 0 {
|
||||||
|
t.Fatalf("could not get port from test http server address %s", httpServer.URL)
|
||||||
|
}
|
||||||
|
port := httpServer.URL[idx+1:]
|
||||||
|
|
||||||
|
ip := srv.runtime.networkManager.bridgeNetwork.IP
|
||||||
|
dockerfile := constructDockerfile(context.dockerfile, ip, port)
|
||||||
|
|
||||||
|
buildfile := NewBuildFile(srv, ioutil.Discard, false)
|
||||||
|
_, err = buildfile.Build(mkTestContext(dockerfile, context.files, t))
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
t.Log("Error should not be nil")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err.Error() != "Forbidden path: /" {
|
||||||
|
t.Logf("Error message is not expected: %s", err.Error())
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package docker
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/dotcloud/docker/utils"
|
||||||
"io"
|
"io"
|
||||||
_ "io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -37,7 +38,7 @@ func setTimeout(t *testing.T, msg string, d time.Duration, f func()) {
|
|||||||
f()
|
f()
|
||||||
c <- false
|
c <- false
|
||||||
}()
|
}()
|
||||||
if <-c {
|
if <-c && msg != "" {
|
||||||
t.Fatal(msg)
|
t.Fatal(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,141 +59,47 @@ func assertPipe(input, output string, r io.Reader, w io.Writer, count int) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*TODO
|
|
||||||
func cmdWait(srv *Server, container *Container) error {
|
|
||||||
stdout, stdoutPipe := io.Pipe()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
srv.CmdWait(nil, stdoutPipe, container.Id)
|
|
||||||
}()
|
|
||||||
|
|
||||||
if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// Cleanup pipes
|
|
||||||
return closeWrap(stdout, stdoutPipe)
|
|
||||||
}
|
|
||||||
|
|
||||||
func cmdImages(srv *Server, args ...string) (string, error) {
|
|
||||||
stdout, stdoutPipe := io.Pipe()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
if err := srv.CmdImages(nil, stdoutPipe, args...); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// force the pipe closed, so that the code below gets an EOF
|
|
||||||
stdoutPipe.Close()
|
|
||||||
}()
|
|
||||||
|
|
||||||
output, err := ioutil.ReadAll(stdout)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup pipes
|
|
||||||
return string(output), closeWrap(stdout, stdoutPipe)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestImages checks that 'docker images' displays information correctly
|
|
||||||
func TestImages(t *testing.T) {
|
|
||||||
|
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
output, err := cmdImages(srv)
|
|
||||||
|
|
||||||
if !strings.Contains(output, "REPOSITORY") {
|
|
||||||
t.Fatal("'images' should have a header")
|
|
||||||
}
|
|
||||||
if !strings.Contains(output, "docker-ut") {
|
|
||||||
t.Fatal("'images' should show the docker-ut image")
|
|
||||||
}
|
|
||||||
if !strings.Contains(output, "e9aa60c60128") {
|
|
||||||
t.Fatal("'images' should show the docker-ut image id")
|
|
||||||
}
|
|
||||||
|
|
||||||
output, err = cmdImages(srv, "-q")
|
|
||||||
|
|
||||||
if strings.Contains(output, "REPOSITORY") {
|
|
||||||
t.Fatal("'images -q' should not have a header")
|
|
||||||
}
|
|
||||||
if strings.Contains(output, "docker-ut") {
|
|
||||||
t.Fatal("'images' should not show the docker-ut image name")
|
|
||||||
}
|
|
||||||
if !strings.Contains(output, "e9aa60c60128") {
|
|
||||||
t.Fatal("'images' should show the docker-ut image id")
|
|
||||||
}
|
|
||||||
|
|
||||||
output, err = cmdImages(srv, "-viz")
|
|
||||||
|
|
||||||
if !strings.HasPrefix(output, "digraph docker {") {
|
|
||||||
t.Fatal("'images -v' should start with the dot header")
|
|
||||||
}
|
|
||||||
if !strings.HasSuffix(output, "}\n") {
|
|
||||||
t.Fatal("'images -v' should end with a '}'")
|
|
||||||
}
|
|
||||||
if !strings.Contains(output, "base -> \"e9aa60c60128\" [style=invis]") {
|
|
||||||
t.Fatal("'images -v' should have the docker-ut image id node")
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: add checks for -a
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestRunHostname checks that 'docker run -h' correctly sets a custom hostname
|
// TestRunHostname checks that 'docker run -h' correctly sets a custom hostname
|
||||||
func TestRunHostname(t *testing.T) {
|
func TestRunHostname(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
stdin, _ := io.Pipe()
|
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
cli := NewDockerCli(nil, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
c := make(chan struct{})
|
c := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
if err := srv.CmdRun(stdin, rcli.NewDockerLocalConn(stdoutPipe), "-h", "foobar", GetTestImage(runtime).Id, "hostname"); err != nil {
|
defer close(c)
|
||||||
|
if err := cli.CmdRun("-h", "foobar", unitTestImageID, "hostname"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
close(c)
|
|
||||||
}()
|
}()
|
||||||
cmdOutput, err := bufio.NewReader(stdout).ReadString('\n')
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if cmdOutput != "foobar\n" {
|
|
||||||
t.Fatalf("'hostname' should display '%s', not '%s'", "foobar\n", cmdOutput)
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(t, "CmdRun timed out", 2*time.Second, func() {
|
setTimeout(t, "Reading command output time out", 2*time.Second, func() {
|
||||||
|
cmdOutput, err := bufio.NewReader(stdout).ReadString('\n')
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if cmdOutput != "foobar\n" {
|
||||||
|
t.Fatalf("'hostname' should display '%s', not '%s'", "foobar\n", cmdOutput)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(t, "CmdRun timed out", 5*time.Second, func() {
|
||||||
<-c
|
<-c
|
||||||
cmdWait(srv, srv.runtime.List()[0])
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunExit(t *testing.T) {
|
func TestRunExit(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
stdin, stdinPipe := io.Pipe()
|
stdin, stdinPipe := io.Pipe()
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
cli := NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
c1 := make(chan struct{})
|
c1 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
srv.CmdRun(stdin, rcli.NewDockerLocalConn(stdoutPipe), "-i", GetTestImage(runtime).Id, "/bin/cat")
|
cli.CmdRun("-i", unitTestImageID, "/bin/cat")
|
||||||
close(c1)
|
close(c1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -202,21 +109,24 @@ func TestRunExit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
container := runtime.List()[0]
|
container := globalRuntime.List()[0]
|
||||||
|
|
||||||
// Closing /bin/cat stdin, expect it to exit
|
// Closing /bin/cat stdin, expect it to exit
|
||||||
p, err := container.StdinPipe()
|
if err := stdin.Close(); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := p.Close(); err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// as the process exited, CmdRun must finish and unblock. Wait for it
|
// as the process exited, CmdRun must finish and unblock. Wait for it
|
||||||
setTimeout(t, "Waiting for CmdRun timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for CmdRun timed out", 10*time.Second, func() {
|
||||||
<-c1
|
<-c1
|
||||||
cmdWait(srv, container)
|
|
||||||
|
go func() {
|
||||||
|
cli.CmdWait(container.ID)
|
||||||
|
}()
|
||||||
|
|
||||||
|
if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Make sure that the client has been disconnected
|
// Make sure that the client has been disconnected
|
||||||
@@ -233,21 +143,18 @@ func TestRunExit(t *testing.T) {
|
|||||||
|
|
||||||
// Expected behaviour: the process dies when the client disconnects
|
// Expected behaviour: the process dies when the client disconnects
|
||||||
func TestRunDisconnect(t *testing.T) {
|
func TestRunDisconnect(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
stdin, stdinPipe := io.Pipe()
|
stdin, stdinPipe := io.Pipe()
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
cli := NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
c1 := make(chan struct{})
|
c1 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
// We're simulating a disconnect so the return value doesn't matter. What matters is the
|
// We're simulating a disconnect so the return value doesn't matter. What matters is the
|
||||||
// fact that CmdRun returns.
|
// fact that CmdRun returns.
|
||||||
srv.CmdRun(stdin, rcli.NewDockerLocalConn(stdoutPipe), "-i", GetTestImage(runtime).Id, "/bin/cat")
|
cli.CmdRun("-i", unitTestImageID, "/bin/cat")
|
||||||
close(c1)
|
close(c1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -271,7 +178,7 @@ func TestRunDisconnect(t *testing.T) {
|
|||||||
// Client disconnect after run -i should cause stdin to be closed, which should
|
// Client disconnect after run -i should cause stdin to be closed, which should
|
||||||
// cause /bin/cat to exit.
|
// cause /bin/cat to exit.
|
||||||
setTimeout(t, "Waiting for /bin/cat to exit timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for /bin/cat to exit timed out", 2*time.Second, func() {
|
||||||
container := runtime.List()[0]
|
container := globalRuntime.List()[0]
|
||||||
container.Wait()
|
container.Wait()
|
||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
t.Fatalf("/bin/cat is still running after closing stdin")
|
t.Fatalf("/bin/cat is still running after closing stdin")
|
||||||
@@ -281,40 +188,39 @@ func TestRunDisconnect(t *testing.T) {
|
|||||||
|
|
||||||
// Expected behaviour: the process dies when the client disconnects
|
// Expected behaviour: the process dies when the client disconnects
|
||||||
func TestRunDisconnectTty(t *testing.T) {
|
func TestRunDisconnectTty(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
stdin, stdinPipe := io.Pipe()
|
stdin, stdinPipe := io.Pipe()
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
cli := NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
c1 := make(chan struct{})
|
c1 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
// We're simulating a disconnect so the return value doesn't matter. What matters is the
|
// We're simulating a disconnect so the return value doesn't matter. What matters is the
|
||||||
// fact that CmdRun returns.
|
// fact that CmdRun returns.
|
||||||
srv.CmdRun(stdin, rcli.NewDockerLocalConn(stdoutPipe), "-i", "-t", GetTestImage(runtime).Id, "/bin/cat")
|
if err := cli.CmdRun("-i", "-t", unitTestImageID, "/bin/cat"); err != nil {
|
||||||
|
utils.Debugf("Error CmdRun: %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
close(c1)
|
close(c1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for the container to be started timed out", 10*time.Second, func() {
|
||||||
for {
|
for {
|
||||||
// Client disconnect after run -i should keep stdin out in TTY mode
|
// Client disconnect after run -i should keep stdin out in TTY mode
|
||||||
l := runtime.List()
|
l := globalRuntime.List()
|
||||||
if len(l) == 1 && l[0].State.Running {
|
if len(l) == 1 && l[0].State.Running {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Client disconnect after run -i should keep stdin out in TTY mode
|
// Client disconnect after run -i should keep stdin out in TTY mode
|
||||||
container := runtime.List()[0]
|
container := globalRuntime.List()[0]
|
||||||
|
|
||||||
setTimeout(t, "Read/Write assertion timed out", 2*time.Second, func() {
|
setTimeout(t, "Read/Write assertion timed out", 2000*time.Second, func() {
|
||||||
if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
|
if err := assertPipe("hello\n", "hello", stdout, stdinPipe, 15); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -339,24 +245,21 @@ func TestRunDisconnectTty(t *testing.T) {
|
|||||||
// 'docker run -i -a stdin' should sends the client's stdin to the command,
|
// 'docker run -i -a stdin' should sends the client's stdin to the command,
|
||||||
// then detach from it and print the container id.
|
// then detach from it and print the container id.
|
||||||
func TestRunAttachStdin(t *testing.T) {
|
func TestRunAttachStdin(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
stdin, stdinPipe := io.Pipe()
|
stdin, stdinPipe := io.Pipe()
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
cli := NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
ch := make(chan struct{})
|
ch := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
srv.CmdRun(stdin, rcli.NewDockerLocalConn(stdoutPipe), "-i", "-a", "stdin", GetTestImage(runtime).Id, "sh", "-c", "echo hello; cat")
|
defer close(ch)
|
||||||
close(ch)
|
cli.CmdRun("-i", "-a", "stdin", unitTestImageID, "sh", "-c", "echo hello && cat")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Send input to the command, close stdin
|
// Send input to the command, close stdin
|
||||||
setTimeout(t, "Write timed out", 2*time.Second, func() {
|
setTimeout(t, "Write timed out", 10*time.Second, func() {
|
||||||
if _, err := stdinPipe.Write([]byte("hi there\n")); err != nil {
|
if _, err := stdinPipe.Write([]byte("hi there\n")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -365,36 +268,42 @@ func TestRunAttachStdin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
container := runtime.List()[0]
|
container := globalRuntime.List()[0]
|
||||||
|
|
||||||
// Check output
|
// Check output
|
||||||
cmdOutput, err := bufio.NewReader(stdout).ReadString('\n')
|
setTimeout(t, "Reading command output time out", 10*time.Second, func() {
|
||||||
if err != nil {
|
cmdOutput, err := bufio.NewReader(stdout).ReadString('\n')
|
||||||
t.Fatal(err)
|
if err != nil {
|
||||||
}
|
t.Fatal(err)
|
||||||
if cmdOutput != container.ShortId()+"\n" {
|
}
|
||||||
t.Fatalf("Wrong output: should be '%s', not '%s'\n", container.ShortId()+"\n", cmdOutput)
|
if cmdOutput != container.ShortID()+"\n" {
|
||||||
}
|
t.Fatalf("Wrong output: should be '%s', not '%s'\n", container.ShortID()+"\n", cmdOutput)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// wait for CmdRun to return
|
// wait for CmdRun to return
|
||||||
setTimeout(t, "Waiting for CmdRun timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for CmdRun timed out", 5*time.Second, func() {
|
||||||
|
// Unblock hijack end
|
||||||
|
stdout.Read([]byte{})
|
||||||
<-ch
|
<-ch
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(t, "Waiting for command to exit timed out", 2*time.Second, func() {
|
setTimeout(t, "Waiting for command to exit timed out", 5*time.Second, func() {
|
||||||
container.Wait()
|
container.Wait()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Check logs
|
// Check logs
|
||||||
if cmdLogs, err := container.ReadLog("stdout"); err != nil {
|
if cmdLogs, err := container.ReadLog("json"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
if output, err := ioutil.ReadAll(cmdLogs); err != nil {
|
if output, err := ioutil.ReadAll(cmdLogs); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
expectedLog := "hello\nhi there\n"
|
expectedLogs := []string{"{\"log\":\"hello\\n\",\"stream\":\"stdout\"", "{\"log\":\"hi there\\n\",\"stream\":\"stdout\""}
|
||||||
if string(output) != expectedLog {
|
for _, expectedLog := range expectedLogs {
|
||||||
t.Fatalf("Unexpected logs: should be '%s', not '%s'\n", expectedLog, output)
|
if !strings.Contains(string(output), expectedLog) {
|
||||||
|
t.Fatalf("Unexpected logs: should contains '%s', it is not '%s'\n", expectedLog, output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,42 +311,43 @@ func TestRunAttachStdin(t *testing.T) {
|
|||||||
|
|
||||||
// Expected behaviour, the process stays alive when the client disconnects
|
// Expected behaviour, the process stays alive when the client disconnects
|
||||||
func TestAttachDisconnect(t *testing.T) {
|
func TestAttachDisconnect(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
|
||||||
|
|
||||||
srv := &Server{runtime: runtime}
|
|
||||||
|
|
||||||
container, err := NewBuilder(runtime).Create(
|
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).Id,
|
|
||||||
CpuShares: 1000,
|
|
||||||
Memory: 33554432,
|
|
||||||
Cmd: []string{"/bin/cat"},
|
|
||||||
OpenStdin: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container)
|
|
||||||
|
|
||||||
// Start the process
|
|
||||||
if err := container.Start(); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
stdin, stdinPipe := io.Pipe()
|
stdin, stdinPipe := io.Pipe()
|
||||||
stdout, stdoutPipe := io.Pipe()
|
stdout, stdoutPipe := io.Pipe()
|
||||||
|
|
||||||
|
cli := NewDockerCli(stdin, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr)
|
||||||
|
defer cleanup(globalRuntime)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// Start a process in daemon mode
|
||||||
|
if err := cli.CmdRun("-d", "-i", unitTestImageID, "/bin/cat"); err != nil {
|
||||||
|
utils.Debugf("Error CmdRun: %s\n", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
setTimeout(t, "Waiting for CmdRun timed out", 10*time.Second, func() {
|
||||||
|
if _, err := bufio.NewReader(stdout).ReadString('\n'); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(t, "Waiting for the container to be started timed out", 10*time.Second, func() {
|
||||||
|
for {
|
||||||
|
l := globalRuntime.List()
|
||||||
|
if len(l) == 1 && l[0].State.Running {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
container := globalRuntime.List()[0]
|
||||||
|
|
||||||
// Attach to it
|
// Attach to it
|
||||||
c1 := make(chan struct{})
|
c1 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
// We're simulating a disconnect so the return value doesn't matter. What matters is the
|
// We're simulating a disconnect so the return value doesn't matter. What matters is the
|
||||||
// fact that CmdAttach returns.
|
// fact that CmdAttach returns.
|
||||||
srv.CmdAttach(stdin, rcli.NewDockerLocalConn(stdoutPipe), container.Id)
|
cli.CmdAttach(container.ID)
|
||||||
close(c1)
|
close(c1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -458,7 +368,7 @@ func TestAttachDisconnect(t *testing.T) {
|
|||||||
|
|
||||||
// We closed stdin, expect /bin/cat to still be running
|
// We closed stdin, expect /bin/cat to still be running
|
||||||
// Wait a little bit to make sure container.monitor() did his thing
|
// Wait a little bit to make sure container.monitor() did his thing
|
||||||
err = container.WaitTimeout(500 * time.Millisecond)
|
err := container.WaitTimeout(500 * time.Millisecond)
|
||||||
if err == nil || !container.State.Running {
|
if err == nil || !container.State.Running {
|
||||||
t.Fatalf("/bin/cat is not running after closing stdin")
|
t.Fatalf("/bin/cat is not running after closing stdin")
|
||||||
}
|
}
|
||||||
@@ -468,4 +378,3 @@ func TestAttachDisconnect(t *testing.T) {
|
|||||||
cStdin.Close()
|
cStdin.Close()
|
||||||
container.Wait()
|
container.Wait()
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|||||||
@@ -52,43 +52,62 @@ type Container struct {
|
|||||||
|
|
||||||
waitLock chan struct{}
|
waitLock chan struct{}
|
||||||
Volumes map[string]string
|
Volumes map[string]string
|
||||||
|
// Store rw/ro in a separate structure to preserve reverse-compatibility on-disk.
|
||||||
|
// Easier than migrating older container configs :)
|
||||||
|
VolumesRW map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Hostname string
|
Hostname string
|
||||||
User string
|
User string
|
||||||
Memory int64 // Memory limit (in bytes)
|
Memory int64 // Memory limit (in bytes)
|
||||||
MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap
|
MemorySwap int64 // Total memory usage (memory + swap); set `-1' to disable swap
|
||||||
CpuShares int64 // CPU shares (relative weight vs. other containers)
|
CpuShares int64 // CPU shares (relative weight vs. other containers)
|
||||||
AttachStdin bool
|
AttachStdin bool
|
||||||
AttachStdout bool
|
AttachStdout bool
|
||||||
AttachStderr bool
|
AttachStderr bool
|
||||||
PortSpecs []string
|
PortSpecs []string
|
||||||
Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
|
Tty bool // Attach standard streams to a tty, including stdin if it is not closed.
|
||||||
OpenStdin bool // Open stdin
|
OpenStdin bool // Open stdin
|
||||||
StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
|
StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
|
||||||
Env []string
|
Env []string
|
||||||
Cmd []string
|
Cmd []string
|
||||||
Dns []string
|
Dns []string
|
||||||
Image string // Name of the image as it was passed by the operator (eg. could be symbolic)
|
Image string // Name of the image as it was passed by the operator (eg. could be symbolic)
|
||||||
Volumes map[string]struct{}
|
Volumes map[string]struct{}
|
||||||
VolumesFrom string
|
VolumesFrom string
|
||||||
|
Entrypoint []string
|
||||||
|
NetworkDisabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseRun(args []string, capabilities *Capabilities) (*Config, *flag.FlagSet, error) {
|
type HostConfig struct {
|
||||||
cmd := Subcmd("run", "[OPTIONS] IMAGE COMMAND [ARG...]", "Run a command in a new container")
|
Binds []string
|
||||||
|
ContainerIDFile string
|
||||||
|
}
|
||||||
|
|
||||||
|
type BindMap struct {
|
||||||
|
SrcPath string
|
||||||
|
DstPath string
|
||||||
|
Mode string
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseRun(args []string, capabilities *Capabilities) (*Config, *HostConfig, *flag.FlagSet, error) {
|
||||||
|
cmd := Subcmd("run", "[OPTIONS] IMAGE [COMMAND] [ARG...]", "Run a command in a new container")
|
||||||
if len(args) > 0 && args[0] != "--help" {
|
if len(args) > 0 && args[0] != "--help" {
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
|
cmd.Usage = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
flHostname := cmd.String("h", "", "Container host name")
|
flHostname := cmd.String("h", "", "Container host name")
|
||||||
flUser := cmd.String("u", "", "Username or UID")
|
flUser := cmd.String("u", "", "Username or UID")
|
||||||
flDetach := cmd.Bool("d", false, "Detached mode: leave the container running in the background")
|
flDetach := cmd.Bool("d", false, "Detached mode: Run container in the background, print new container id")
|
||||||
flAttach := NewAttachOpts()
|
flAttach := NewAttachOpts()
|
||||||
cmd.Var(flAttach, "a", "Attach to stdin, stdout or stderr.")
|
cmd.Var(flAttach, "a", "Attach to stdin, stdout or stderr.")
|
||||||
flStdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
|
flStdin := cmd.Bool("i", false, "Keep stdin open even if not attached")
|
||||||
flTty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
flTty := cmd.Bool("t", false, "Allocate a pseudo-tty")
|
||||||
flMemory := cmd.Int64("m", 0, "Memory limit (in bytes)")
|
flMemory := cmd.Int64("m", 0, "Memory limit (in bytes)")
|
||||||
|
flContainerIDFile := cmd.String("cidfile", "", "Write the container ID to the file")
|
||||||
|
flNetwork := cmd.Bool("n", true, "Enable networking for this container")
|
||||||
|
|
||||||
if capabilities != nil && *flMemory > 0 && !capabilities.MemoryLimit {
|
if capabilities != nil && *flMemory > 0 && !capabilities.MemoryLimit {
|
||||||
//fmt.Fprintf(stdout, "WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
|
//fmt.Fprintf(stdout, "WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n")
|
||||||
@@ -107,15 +126,16 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *flag.FlagSet
|
|||||||
cmd.Var(&flDns, "dns", "Set custom dns servers")
|
cmd.Var(&flDns, "dns", "Set custom dns servers")
|
||||||
|
|
||||||
flVolumes := NewPathOpts()
|
flVolumes := NewPathOpts()
|
||||||
cmd.Var(flVolumes, "v", "Attach a data volume")
|
cmd.Var(flVolumes, "v", "Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)")
|
||||||
|
|
||||||
flVolumesFrom := cmd.String("volumes-from", "", "Mount volumes from the specified container")
|
flVolumesFrom := cmd.String("volumes-from", "", "Mount volumes from the specified container")
|
||||||
|
flEntrypoint := cmd.String("entrypoint", "", "Overwrite the default entrypoint of the image")
|
||||||
|
|
||||||
if err := cmd.Parse(args); err != nil {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil, cmd, err
|
return nil, nil, cmd, err
|
||||||
}
|
}
|
||||||
if *flDetach && len(flAttach) > 0 {
|
if *flDetach && len(flAttach) > 0 {
|
||||||
return nil, cmd, fmt.Errorf("Conflicting options: -a and -d")
|
return nil, nil, cmd, fmt.Errorf("Conflicting options: -a and -d")
|
||||||
}
|
}
|
||||||
// If neither -d or -a are set, attach to everything by default
|
// If neither -d or -a are set, attach to everything by default
|
||||||
if len(flAttach) == 0 && !*flDetach {
|
if len(flAttach) == 0 && !*flDetach {
|
||||||
@@ -127,8 +147,23 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *flag.FlagSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var binds []string
|
||||||
|
|
||||||
|
// add any bind targets to the list of container volumes
|
||||||
|
for bind := range flVolumes {
|
||||||
|
arr := strings.Split(bind, ":")
|
||||||
|
if len(arr) > 1 {
|
||||||
|
dstDir := arr[1]
|
||||||
|
flVolumes[dstDir] = struct{}{}
|
||||||
|
binds = append(binds, bind)
|
||||||
|
delete(flVolumes, bind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
parsedArgs := cmd.Args()
|
parsedArgs := cmd.Args()
|
||||||
runCmd := []string{}
|
runCmd := []string{}
|
||||||
|
entrypoint := []string{}
|
||||||
image := ""
|
image := ""
|
||||||
if len(parsedArgs) >= 1 {
|
if len(parsedArgs) >= 1 {
|
||||||
image = cmd.Arg(0)
|
image = cmd.Arg(0)
|
||||||
@@ -136,23 +171,33 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *flag.FlagSet
|
|||||||
if len(parsedArgs) > 1 {
|
if len(parsedArgs) > 1 {
|
||||||
runCmd = parsedArgs[1:]
|
runCmd = parsedArgs[1:]
|
||||||
}
|
}
|
||||||
|
if *flEntrypoint != "" {
|
||||||
|
entrypoint = []string{*flEntrypoint}
|
||||||
|
}
|
||||||
|
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Hostname: *flHostname,
|
Hostname: *flHostname,
|
||||||
PortSpecs: flPorts,
|
PortSpecs: flPorts,
|
||||||
User: *flUser,
|
User: *flUser,
|
||||||
Tty: *flTty,
|
Tty: *flTty,
|
||||||
OpenStdin: *flStdin,
|
NetworkDisabled: !*flNetwork,
|
||||||
Memory: *flMemory,
|
OpenStdin: *flStdin,
|
||||||
CpuShares: *flCpuShares,
|
Memory: *flMemory,
|
||||||
AttachStdin: flAttach.Get("stdin"),
|
CpuShares: *flCpuShares,
|
||||||
AttachStdout: flAttach.Get("stdout"),
|
AttachStdin: flAttach.Get("stdin"),
|
||||||
AttachStderr: flAttach.Get("stderr"),
|
AttachStdout: flAttach.Get("stdout"),
|
||||||
Env: flEnv,
|
AttachStderr: flAttach.Get("stderr"),
|
||||||
Cmd: runCmd,
|
Env: flEnv,
|
||||||
Dns: flDns,
|
Cmd: runCmd,
|
||||||
Image: image,
|
Dns: flDns,
|
||||||
Volumes: flVolumes,
|
Image: image,
|
||||||
VolumesFrom: *flVolumesFrom,
|
Volumes: flVolumes,
|
||||||
|
VolumesFrom: *flVolumesFrom,
|
||||||
|
Entrypoint: entrypoint,
|
||||||
|
}
|
||||||
|
hostConfig := &HostConfig{
|
||||||
|
Binds: binds,
|
||||||
|
ContainerIDFile: *flContainerIDFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
if capabilities != nil && *flMemory > 0 && !capabilities.SwapLimit {
|
if capabilities != nil && *flMemory > 0 && !capabilities.SwapLimit {
|
||||||
@@ -164,23 +209,28 @@ func ParseRun(args []string, capabilities *Capabilities) (*Config, *flag.FlagSet
|
|||||||
if config.OpenStdin && config.AttachStdin {
|
if config.OpenStdin && config.AttachStdin {
|
||||||
config.StdinOnce = true
|
config.StdinOnce = true
|
||||||
}
|
}
|
||||||
return config, cmd, nil
|
return config, hostConfig, cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PortMapping map[string]string
|
||||||
|
|
||||||
type NetworkSettings struct {
|
type NetworkSettings struct {
|
||||||
IPAddress string
|
IPAddress string
|
||||||
IPPrefixLen int
|
IPPrefixLen int
|
||||||
Gateway string
|
Gateway string
|
||||||
Bridge string
|
Bridge string
|
||||||
PortMapping map[string]string
|
PortMapping map[string]PortMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a human-readable description of the port mapping defined in the settings
|
// String returns a human-readable description of the port mapping defined in the settings
|
||||||
func (settings *NetworkSettings) PortMappingHuman() string {
|
func (settings *NetworkSettings) PortMappingHuman() string {
|
||||||
var mapping []string
|
var mapping []string
|
||||||
for private, public := range settings.PortMapping {
|
for private, public := range settings.PortMapping["Tcp"] {
|
||||||
mapping = append(mapping, fmt.Sprintf("%s->%s", public, private))
|
mapping = append(mapping, fmt.Sprintf("%s->%s", public, private))
|
||||||
}
|
}
|
||||||
|
for private, public := range settings.PortMapping["Udp"] {
|
||||||
|
mapping = append(mapping, fmt.Sprintf("%s->%s/udp", public, private))
|
||||||
|
}
|
||||||
sort.Strings(mapping)
|
sort.Strings(mapping)
|
||||||
return strings.Join(mapping, ", ")
|
return strings.Join(mapping, ", ")
|
||||||
}
|
}
|
||||||
@@ -230,6 +280,26 @@ func (container *Container) ToDisk() (err error) {
|
|||||||
return ioutil.WriteFile(container.jsonPath(), data, 0666)
|
return ioutil.WriteFile(container.jsonPath(), data, 0666)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (container *Container) ReadHostConfig() (*HostConfig, error) {
|
||||||
|
data, err := ioutil.ReadFile(container.hostConfigPath())
|
||||||
|
if err != nil {
|
||||||
|
return &HostConfig{}, err
|
||||||
|
}
|
||||||
|
hostConfig := &HostConfig{}
|
||||||
|
if err := json.Unmarshal(data, hostConfig); err != nil {
|
||||||
|
return &HostConfig{}, err
|
||||||
|
}
|
||||||
|
return hostConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (container *Container) SaveHostConfig(hostConfig *HostConfig) (err error) {
|
||||||
|
data, err := json.Marshal(hostConfig)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ioutil.WriteFile(container.hostConfigPath(), data, 0666)
|
||||||
|
}
|
||||||
|
|
||||||
func (container *Container) generateLXCConfig() error {
|
func (container *Container) generateLXCConfig() error {
|
||||||
fo, err := os.Create(container.lxcConfigPath())
|
fo, err := os.Create(container.lxcConfigPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -309,14 +379,15 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
|
|||||||
utils.Debugf("[start] attach stdin\n")
|
utils.Debugf("[start] attach stdin\n")
|
||||||
defer utils.Debugf("[end] attach stdin\n")
|
defer utils.Debugf("[end] attach stdin\n")
|
||||||
// No matter what, when stdin is closed (io.Copy unblock), close stdout and stderr
|
// No matter what, when stdin is closed (io.Copy unblock), close stdout and stderr
|
||||||
if cStdout != nil {
|
|
||||||
defer cStdout.Close()
|
|
||||||
}
|
|
||||||
if cStderr != nil {
|
|
||||||
defer cStderr.Close()
|
|
||||||
}
|
|
||||||
if container.Config.StdinOnce && !container.Config.Tty {
|
if container.Config.StdinOnce && !container.Config.Tty {
|
||||||
defer cStdin.Close()
|
defer cStdin.Close()
|
||||||
|
} else {
|
||||||
|
if cStdout != nil {
|
||||||
|
defer cStdout.Close()
|
||||||
|
}
|
||||||
|
if cStderr != nil {
|
||||||
|
defer cStderr.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if container.Config.Tty {
|
if container.Config.Tty {
|
||||||
_, err = utils.CopyEscapable(cStdin, stdin)
|
_, err = utils.CopyEscapable(cStdin, stdin)
|
||||||
@@ -430,9 +501,13 @@ func (container *Container) Attach(stdin io.ReadCloser, stdinCloser io.Closer, s
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Start() error {
|
func (container *Container) Start(hostConfig *HostConfig) error {
|
||||||
container.State.lock()
|
container.State.Lock()
|
||||||
defer container.State.unlock()
|
defer container.State.Unlock()
|
||||||
|
|
||||||
|
if len(hostConfig.Binds) == 0 {
|
||||||
|
hostConfig, _ = container.ReadHostConfig()
|
||||||
|
}
|
||||||
|
|
||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
return fmt.Errorf("The container %s is already running.", container.ID)
|
return fmt.Errorf("The container %s is already running.", container.ID)
|
||||||
@@ -440,8 +515,12 @@ func (container *Container) Start() error {
|
|||||||
if err := container.EnsureMounted(); err != nil {
|
if err := container.EnsureMounted(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := container.allocateNetwork(); err != nil {
|
if container.runtime.networkManager.disabled {
|
||||||
return err
|
container.Config.NetworkDisabled = true
|
||||||
|
} else {
|
||||||
|
if err := container.allocateNetwork(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the config is compatible with the current kernel
|
// Make sure the config is compatible with the current kernel
|
||||||
@@ -453,18 +532,75 @@ func (container *Container) Start() error {
|
|||||||
log.Printf("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
|
log.Printf("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
|
||||||
container.Config.MemorySwap = -1
|
container.Config.MemorySwap = -1
|
||||||
}
|
}
|
||||||
container.Volumes = make(map[string]string)
|
|
||||||
|
|
||||||
|
// Create the requested bind mounts
|
||||||
|
binds := make(map[string]BindMap)
|
||||||
|
// Define illegal container destinations
|
||||||
|
illegalDsts := []string{"/", "."}
|
||||||
|
|
||||||
|
for _, bind := range hostConfig.Binds {
|
||||||
|
// FIXME: factorize bind parsing in parseBind
|
||||||
|
var src, dst, mode string
|
||||||
|
arr := strings.Split(bind, ":")
|
||||||
|
if len(arr) == 2 {
|
||||||
|
src = arr[0]
|
||||||
|
dst = arr[1]
|
||||||
|
mode = "rw"
|
||||||
|
} else if len(arr) == 3 {
|
||||||
|
src = arr[0]
|
||||||
|
dst = arr[1]
|
||||||
|
mode = arr[2]
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("Invalid bind specification: %s", bind)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bail if trying to mount to an illegal destination
|
||||||
|
for _, illegal := range illegalDsts {
|
||||||
|
if dst == illegal {
|
||||||
|
return fmt.Errorf("Illegal bind destination: %s", dst)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bindMap := BindMap{
|
||||||
|
SrcPath: src,
|
||||||
|
DstPath: dst,
|
||||||
|
Mode: mode,
|
||||||
|
}
|
||||||
|
binds[path.Clean(dst)] = bindMap
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: evaluate volumes-from before individual volumes, so that the latter can override the former.
|
||||||
// Create the requested volumes volumes
|
// Create the requested volumes volumes
|
||||||
for volPath := range container.Config.Volumes {
|
if container.Volumes == nil || len(container.Volumes) == 0 {
|
||||||
c, err := container.runtime.volumes.Create(nil, container, "", "", nil)
|
container.Volumes = make(map[string]string)
|
||||||
if err != nil {
|
container.VolumesRW = make(map[string]bool)
|
||||||
return err
|
|
||||||
|
for volPath := range container.Config.Volumes {
|
||||||
|
volPath = path.Clean(volPath)
|
||||||
|
// If an external bind is defined for this volume, use that as a source
|
||||||
|
if bindMap, exists := binds[volPath]; exists {
|
||||||
|
container.Volumes[volPath] = bindMap.SrcPath
|
||||||
|
if strings.ToLower(bindMap.Mode) == "rw" {
|
||||||
|
container.VolumesRW[volPath] = true
|
||||||
|
}
|
||||||
|
// Otherwise create an directory in $ROOT/volumes/ and use that
|
||||||
|
} else {
|
||||||
|
c, err := container.runtime.volumes.Create(nil, container, "", "", nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
srcPath, err := c.layer()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
container.Volumes[volPath] = srcPath
|
||||||
|
container.VolumesRW[volPath] = true // RW by default
|
||||||
|
}
|
||||||
|
// Create the mountpoint
|
||||||
|
if err := os.MkdirAll(path.Join(container.RootfsPath(), volPath), 0755); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(path.Join(container.RootfsPath(), volPath), 0755); err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
container.Volumes[volPath] = c.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if container.Config.VolumesFrom != "" {
|
if container.Config.VolumesFrom != "" {
|
||||||
@@ -480,6 +616,9 @@ func (container *Container) Start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
container.Volumes[volPath] = id
|
container.Volumes[volPath] = id
|
||||||
|
if isRW, exists := c.VolumesRW[volPath]; exists {
|
||||||
|
container.VolumesRW[volPath] = isRW
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,7 +634,9 @@ func (container *Container) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Networking
|
// Networking
|
||||||
params = append(params, "-g", container.network.Gateway.String())
|
if !container.Config.NetworkDisabled {
|
||||||
|
params = append(params, "-g", container.network.Gateway.String())
|
||||||
|
}
|
||||||
|
|
||||||
// User
|
// User
|
||||||
if container.Config.User != "" {
|
if container.Config.User != "" {
|
||||||
@@ -510,6 +651,7 @@ func (container *Container) Start() error {
|
|||||||
params = append(params,
|
params = append(params,
|
||||||
"-e", "HOME=/",
|
"-e", "HOME=/",
|
||||||
"-e", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"-e", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
|
"-e", "container=lxc",
|
||||||
)
|
)
|
||||||
|
|
||||||
for _, elem := range container.Config.Env {
|
for _, elem := range container.Config.Env {
|
||||||
@@ -523,10 +665,10 @@ func (container *Container) Start() error {
|
|||||||
container.cmd = exec.Command("lxc-start", params...)
|
container.cmd = exec.Command("lxc-start", params...)
|
||||||
|
|
||||||
// Setup logging of stdout and stderr to disk
|
// Setup logging of stdout and stderr to disk
|
||||||
if err := container.runtime.LogToDisk(container.stdout, container.logPath("stdout")); err != nil {
|
if err := container.runtime.LogToDisk(container.stdout, container.logPath("json"), "stdout"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := container.runtime.LogToDisk(container.stderr, container.logPath("stderr")); err != nil {
|
if err := container.runtime.LogToDisk(container.stderr, container.logPath("json"), "stderr"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,12 +689,14 @@ func (container *Container) Start() error {
|
|||||||
container.waitLock = make(chan struct{})
|
container.waitLock = make(chan struct{})
|
||||||
|
|
||||||
container.ToDisk()
|
container.ToDisk()
|
||||||
|
container.SaveHostConfig(hostConfig)
|
||||||
go container.monitor()
|
go container.monitor()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Run() error {
|
func (container *Container) Run() error {
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.Wait()
|
container.Wait()
|
||||||
@@ -565,7 +709,8 @@ func (container *Container) Output() (output []byte, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer pipe.Close()
|
defer pipe.Close()
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
output, err = ioutil.ReadAll(pipe)
|
output, err = ioutil.ReadAll(pipe)
|
||||||
@@ -582,29 +727,37 @@ func (container *Container) StdinPipe() (io.WriteCloser, error) {
|
|||||||
|
|
||||||
func (container *Container) StdoutPipe() (io.ReadCloser, error) {
|
func (container *Container) StdoutPipe() (io.ReadCloser, error) {
|
||||||
reader, writer := io.Pipe()
|
reader, writer := io.Pipe()
|
||||||
container.stdout.AddWriter(writer)
|
container.stdout.AddWriter(writer, "")
|
||||||
return utils.NewBufReader(reader), nil
|
return utils.NewBufReader(reader), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) StderrPipe() (io.ReadCloser, error) {
|
func (container *Container) StderrPipe() (io.ReadCloser, error) {
|
||||||
reader, writer := io.Pipe()
|
reader, writer := io.Pipe()
|
||||||
container.stderr.AddWriter(writer)
|
container.stderr.AddWriter(writer, "")
|
||||||
return utils.NewBufReader(reader), nil
|
return utils.NewBufReader(reader), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) allocateNetwork() error {
|
func (container *Container) allocateNetwork() error {
|
||||||
|
if container.Config.NetworkDisabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
iface, err := container.runtime.networkManager.Allocate()
|
iface, err := container.runtime.networkManager.Allocate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.NetworkSettings.PortMapping = make(map[string]string)
|
container.NetworkSettings.PortMapping = make(map[string]PortMapping)
|
||||||
|
container.NetworkSettings.PortMapping["Tcp"] = make(PortMapping)
|
||||||
|
container.NetworkSettings.PortMapping["Udp"] = make(PortMapping)
|
||||||
for _, spec := range container.Config.PortSpecs {
|
for _, spec := range container.Config.PortSpecs {
|
||||||
nat, err := iface.AllocatePort(spec)
|
nat, err := iface.AllocatePort(spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
iface.Release()
|
iface.Release()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.NetworkSettings.PortMapping[strconv.Itoa(nat.Backend)] = strconv.Itoa(nat.Frontend)
|
proto := strings.Title(nat.Proto)
|
||||||
|
backend, frontend := strconv.Itoa(nat.Backend), strconv.Itoa(nat.Frontend)
|
||||||
|
container.NetworkSettings.PortMapping[proto][backend] = frontend
|
||||||
}
|
}
|
||||||
container.network = iface
|
container.network = iface
|
||||||
container.NetworkSettings.Bridge = container.runtime.networkManager.bridgeIface
|
container.NetworkSettings.Bridge = container.runtime.networkManager.bridgeIface
|
||||||
@@ -615,6 +768,9 @@ func (container *Container) allocateNetwork() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) releaseNetwork() {
|
func (container *Container) releaseNetwork() {
|
||||||
|
if container.Config.NetworkDisabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
container.network.Release()
|
container.network.Release()
|
||||||
container.network = nil
|
container.network = nil
|
||||||
container.NetworkSettings = &NetworkSettings{}
|
container.NetworkSettings = &NetworkSettings{}
|
||||||
@@ -632,7 +788,6 @@ func (container *Container) waitLxc() error {
|
|||||||
}
|
}
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
}
|
}
|
||||||
panic("Unreachable")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) monitor() {
|
func (container *Container) monitor() {
|
||||||
@@ -651,7 +806,9 @@ func (container *Container) monitor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
utils.Debugf("Process finished")
|
utils.Debugf("Process finished")
|
||||||
|
if container.runtime != nil && container.runtime.srv != nil {
|
||||||
|
container.runtime.srv.LogEvent("die", container.ShortID())
|
||||||
|
}
|
||||||
exitCode := -1
|
exitCode := -1
|
||||||
if container.cmd != nil {
|
if container.cmd != nil {
|
||||||
exitCode = container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
exitCode = container.cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
|
||||||
@@ -731,8 +888,8 @@ func (container *Container) kill() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Kill() error {
|
func (container *Container) Kill() error {
|
||||||
container.State.lock()
|
container.State.Lock()
|
||||||
defer container.State.unlock()
|
defer container.State.Unlock()
|
||||||
if !container.State.Running {
|
if !container.State.Running {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -740,8 +897,8 @@ func (container *Container) Kill() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) Stop(seconds int) error {
|
func (container *Container) Stop(seconds int) error {
|
||||||
container.State.lock()
|
container.State.Lock()
|
||||||
defer container.State.unlock()
|
defer container.State.Unlock()
|
||||||
if !container.State.Running {
|
if !container.State.Running {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -769,7 +926,8 @@ func (container *Container) Restart(seconds int) error {
|
|||||||
if err := container.Stop(seconds); err != nil {
|
if err := container.Stop(seconds); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -821,8 +979,6 @@ func (container *Container) WaitTimeout(timeout time.Duration) error {
|
|||||||
case <-done:
|
case <-done:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("Unreachable")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) EnsureMounted() error {
|
func (container *Container) EnsureMounted() error {
|
||||||
@@ -881,6 +1037,10 @@ func (container *Container) ReadLog(name string) (io.Reader, error) {
|
|||||||
return os.Open(container.logPath(name))
|
return os.Open(container.logPath(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (container *Container) hostConfigPath() string {
|
||||||
|
return path.Join(container.root, "hostconfig.json")
|
||||||
|
}
|
||||||
|
|
||||||
func (container *Container) jsonPath() string {
|
func (container *Container) jsonPath() string {
|
||||||
return path.Join(container.root, "config.json")
|
return path.Join(container.root, "config.json")
|
||||||
}
|
}
|
||||||
@@ -894,22 +1054,6 @@ func (container *Container) RootfsPath() string {
|
|||||||
return path.Join(container.root, "rootfs")
|
return path.Join(container.root, "rootfs")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) GetVolumes() (map[string]string, error) {
|
|
||||||
ret := make(map[string]string)
|
|
||||||
for volPath, id := range container.Volumes {
|
|
||||||
volume, err := container.runtime.volumes.Get(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
root, err := volume.root()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ret[volPath] = path.Join(root, "layer")
|
|
||||||
}
|
|
||||||
return ret, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (container *Container) rwPath() string {
|
func (container *Container) rwPath() string {
|
||||||
return path.Join(container.root, "rw")
|
return path.Join(container.root, "rw")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -15,10 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestIDFormat(t *testing.T) {
|
func TestIDFormat(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container1, err := NewBuilder(runtime).Create(
|
container1, err := NewBuilder(runtime).Create(
|
||||||
&Config{
|
&Config{
|
||||||
@@ -39,21 +37,13 @@ func TestIDFormat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMultipleAttachRestart(t *testing.T) {
|
func TestMultipleAttachRestart(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(
|
container, hostConfig, _ := mkContainer(
|
||||||
&Config{
|
runtime,
|
||||||
Image: GetTestImage(runtime).ID,
|
[]string{"_", "/bin/sh", "-c", "i=1; while [ $i -le 5 ]; do i=`expr $i + 1`; echo hello; done"},
|
||||||
Cmd: []string{"/bin/sh", "-c",
|
t,
|
||||||
"i=1; while [ $i -le 5 ]; do i=`expr $i + 1`; echo hello; done"},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
// Simulate 3 client attaching to the container and stop/restart
|
// Simulate 3 client attaching to the container and stop/restart
|
||||||
@@ -70,7 +60,7 @@ func TestMultipleAttachRestart(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
l1, err := bufio.NewReader(stdout1).ReadString('\n')
|
l1, err := bufio.NewReader(stdout1).ReadString('\n')
|
||||||
@@ -111,7 +101,7 @@ func TestMultipleAttachRestart(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,24 +132,10 @@ func TestMultipleAttachRestart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDiff(t *testing.T) {
|
func TestDiff(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
builder := NewBuilder(runtime)
|
|
||||||
|
|
||||||
// Create a container and remove a file
|
// Create a container and remove a file
|
||||||
container1, err := builder.Create(
|
container1, _, _ := mkContainer(runtime, []string{"_", "/bin/rm", "/etc/passwd"}, t)
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).ID,
|
|
||||||
Cmd: []string{"/bin/rm", "/etc/passwd"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container1)
|
defer runtime.Destroy(container1)
|
||||||
|
|
||||||
if err := container1.Run(); err != nil {
|
if err := container1.Run(); err != nil {
|
||||||
@@ -192,15 +168,7 @@ func TestDiff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new container from the commited image
|
// Create a new container from the commited image
|
||||||
container2, err := builder.Create(
|
container2, _, _ := mkContainer(runtime, []string{img.ID, "cat", "/etc/passwd"}, t)
|
||||||
&Config{
|
|
||||||
Image: img.ID,
|
|
||||||
Cmd: []string{"cat", "/etc/passwd"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container2)
|
defer runtime.Destroy(container2)
|
||||||
|
|
||||||
if err := container2.Run(); err != nil {
|
if err := container2.Run(); err != nil {
|
||||||
@@ -219,15 +187,7 @@ func TestDiff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new containere
|
// Create a new containere
|
||||||
container3, err := builder.Create(
|
container3, _, _ := mkContainer(runtime, []string{"_", "rm", "/bin/httpd"}, t)
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).ID,
|
|
||||||
Cmd: []string{"rm", "/bin/httpd"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container3)
|
defer runtime.Destroy(container3)
|
||||||
|
|
||||||
if err := container3.Run(); err != nil {
|
if err := container3.Run(); err != nil {
|
||||||
@@ -251,22 +211,9 @@ func TestDiff(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCommitAutoRun(t *testing.T) {
|
func TestCommitAutoRun(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
container1, _, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "echo hello > /world"}, t)
|
||||||
builder := NewBuilder(runtime)
|
|
||||||
container1, err := builder.Create(
|
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).ID,
|
|
||||||
Cmd: []string{"/bin/sh", "-c", "echo hello > /world"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container1)
|
defer runtime.Destroy(container1)
|
||||||
|
|
||||||
if container1.State.Running {
|
if container1.State.Running {
|
||||||
@@ -289,14 +236,7 @@ func TestCommitAutoRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world
|
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world
|
||||||
container2, err := builder.Create(
|
container2, hostConfig, _ := mkContainer(runtime, []string{img.ID}, t)
|
||||||
&Config{
|
|
||||||
Image: img.ID,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container2)
|
defer runtime.Destroy(container2)
|
||||||
stdout, err := container2.StdoutPipe()
|
stdout, err := container2.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -306,7 +246,7 @@ func TestCommitAutoRun(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container2.Start(); err != nil {
|
if err := container2.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
container2.Wait()
|
container2.Wait()
|
||||||
@@ -330,23 +270,10 @@ func TestCommitAutoRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCommitRun(t *testing.T) {
|
func TestCommitRun(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
builder := NewBuilder(runtime)
|
container1, hostConfig, _ := mkContainer(runtime, []string{"_", "/bin/sh", "-c", "echo hello > /world"}, t)
|
||||||
|
|
||||||
container1, err := builder.Create(
|
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).ID,
|
|
||||||
Cmd: []string{"/bin/sh", "-c", "echo hello > /world"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container1)
|
defer runtime.Destroy(container1)
|
||||||
|
|
||||||
if container1.State.Running {
|
if container1.State.Running {
|
||||||
@@ -369,16 +296,7 @@ func TestCommitRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world
|
// FIXME: Make a TestCommit that stops here and check docker.root/layers/img.id/world
|
||||||
|
container2, hostConfig, _ := mkContainer(runtime, []string{img.ID, "cat", "/world"}, t)
|
||||||
container2, err := builder.Create(
|
|
||||||
&Config{
|
|
||||||
Image: img.ID,
|
|
||||||
Cmd: []string{"cat", "/world"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container2)
|
defer runtime.Destroy(container2)
|
||||||
stdout, err := container2.StdoutPipe()
|
stdout, err := container2.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -388,7 +306,7 @@ func TestCommitRun(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container2.Start(); err != nil {
|
if err := container2.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
container2.Wait()
|
container2.Wait()
|
||||||
@@ -412,23 +330,9 @@ func TestCommitRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStart(t *testing.T) {
|
func TestStart(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(
|
container, hostConfig, _ := mkContainer(runtime, []string{"-m", "33554432", "-c", "1000", "-i", "_", "/bin/cat"}, t)
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).ID,
|
|
||||||
Memory: 33554432,
|
|
||||||
CpuShares: 1000,
|
|
||||||
Cmd: []string{"/bin/cat"},
|
|
||||||
OpenStdin: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
cStdin, err := container.StdinPipe()
|
cStdin, err := container.StdinPipe()
|
||||||
@@ -436,7 +340,7 @@ func TestStart(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := container.Start(); err != nil {
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,7 +350,7 @@ func TestStart(t *testing.T) {
|
|||||||
if !container.State.Running {
|
if !container.State.Running {
|
||||||
t.Errorf("Container should be running")
|
t.Errorf("Container should be running")
|
||||||
}
|
}
|
||||||
if err := container.Start(); err == nil {
|
if err := container.Start(hostConfig); err == nil {
|
||||||
t.Fatalf("A running containter should be able to be started")
|
t.Fatalf("A running containter should be able to be started")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,20 +360,9 @@ func TestStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRun(t *testing.T) {
|
func TestRun(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(
|
container, _, _ := mkContainer(runtime, []string{"_", "ls", "-al"}, t)
|
||||||
&Config{
|
|
||||||
Image: GetTestImage(runtime).ID,
|
|
||||||
Cmd: []string{"ls", "-al"},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
@@ -484,10 +377,7 @@ func TestRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOutput(t *testing.T) {
|
func TestOutput(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(
|
container, err := NewBuilder(runtime).Create(
|
||||||
&Config{
|
&Config{
|
||||||
@@ -509,10 +399,7 @@ func TestOutput(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestKillDifferentUser(t *testing.T) {
|
func TestKillDifferentUser(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
@@ -528,16 +415,19 @@ func TestKillDifferentUser(t *testing.T) {
|
|||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
t.Errorf("Container shouldn't be running")
|
t.Errorf("Container shouldn't be running")
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give some time to lxc to spawn the process (setuid might take some time)
|
setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
|
||||||
container.WaitTimeout(500 * time.Millisecond)
|
for !container.State.Running {
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if !container.State.Running {
|
// Even if the state is running, lets give some time to lxc to spawn the process
|
||||||
t.Errorf("Container should be running")
|
container.WaitTimeout(500 * time.Millisecond)
|
||||||
}
|
|
||||||
|
|
||||||
if err := container.Kill(); err != nil {
|
if err := container.Kill(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -556,15 +446,33 @@ func TestKillDifferentUser(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKill(t *testing.T) {
|
// Test that creating a container with a volume doesn't crash. Regression test for #995.
|
||||||
runtime, err := newTestRuntime()
|
func TestCreateVolume(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
config, hc, _, err := ParseRun([]string{"-v", "/var/lib/data", GetTestImage(runtime).ID, "echo", "hello", "world"}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
c, err := NewBuilder(runtime).Create(config)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(c)
|
||||||
|
if err := c.Start(hc); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
c.WaitTimeout(500 * time.Millisecond)
|
||||||
|
c.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestKill(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
Cmd: []string{"cat", "/dev/zero"},
|
Cmd: []string{"sleep", "2"},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -575,7 +483,8 @@ func TestKill(t *testing.T) {
|
|||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
t.Errorf("Container shouldn't be running")
|
t.Errorf("Container shouldn't be running")
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,10 +511,7 @@ func TestKill(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestExitCode(t *testing.T) {
|
func TestExitCode(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
builder := NewBuilder(runtime)
|
builder := NewBuilder(runtime)
|
||||||
@@ -642,10 +548,7 @@ func TestExitCode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRestart(t *testing.T) {
|
func TestRestart(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
@@ -675,10 +578,7 @@ func TestRestart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRestartStdin(t *testing.T) {
|
func TestRestartStdin(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
@@ -700,7 +600,8 @@ func TestRestartStdin(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if _, err := io.WriteString(stdin, "hello world"); err != nil {
|
if _, err := io.WriteString(stdin, "hello world"); err != nil {
|
||||||
@@ -730,7 +631,7 @@ func TestRestartStdin(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if _, err := io.WriteString(stdin, "hello world #2"); err != nil {
|
if _, err := io.WriteString(stdin, "hello world #2"); err != nil {
|
||||||
@@ -753,10 +654,7 @@ func TestRestartStdin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUser(t *testing.T) {
|
func TestUser(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
builder := NewBuilder(runtime)
|
builder := NewBuilder(runtime)
|
||||||
@@ -860,20 +758,34 @@ func TestUser(t *testing.T) {
|
|||||||
if !strings.Contains(string(output), "uid=1(daemon) gid=1(daemon)") {
|
if !strings.Contains(string(output), "uid=1(daemon) gid=1(daemon)") {
|
||||||
t.Error(string(output))
|
t.Error(string(output))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func TestMultipleContainers(t *testing.T) {
|
// Test an wrong username
|
||||||
runtime, err := newTestRuntime()
|
container, err = builder.Create(&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"id"},
|
||||||
|
|
||||||
|
User: "unkownuser",
|
||||||
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
output, err = container.Output()
|
||||||
|
if container.State.ExitCode == 0 {
|
||||||
|
t.Fatal("Starting container with wrong uid should fail but it passed.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMultipleContainers(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
builder := NewBuilder(runtime)
|
builder := NewBuilder(runtime)
|
||||||
|
|
||||||
container1, err := builder.Create(&Config{
|
container1, err := builder.Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
Cmd: []string{"cat", "/dev/zero"},
|
Cmd: []string{"sleep", "2"},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -883,7 +795,7 @@ func TestMultipleContainers(t *testing.T) {
|
|||||||
|
|
||||||
container2, err := builder.Create(&Config{
|
container2, err := builder.Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
Cmd: []string{"cat", "/dev/zero"},
|
Cmd: []string{"sleep", "2"},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -892,10 +804,11 @@ func TestMultipleContainers(t *testing.T) {
|
|||||||
defer runtime.Destroy(container2)
|
defer runtime.Destroy(container2)
|
||||||
|
|
||||||
// Start both containers
|
// Start both containers
|
||||||
if err := container1.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container1.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container2.Start(); err != nil {
|
if err := container2.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,10 +835,7 @@ func TestMultipleContainers(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStdin(t *testing.T) {
|
func TestStdin(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
@@ -947,7 +857,8 @@ func TestStdin(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer stdin.Close()
|
defer stdin.Close()
|
||||||
@@ -969,10 +880,7 @@ func TestStdin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTty(t *testing.T) {
|
func TestTty(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
@@ -994,7 +902,8 @@ func TestTty(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer stdin.Close()
|
defer stdin.Close()
|
||||||
@@ -1016,14 +925,11 @@ func TestTty(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEnv(t *testing.T) {
|
func TestEnv(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
Cmd: []string{"/usr/bin/env"},
|
Cmd: []string{"env"},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1036,7 +942,8 @@ func TestEnv(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer stdout.Close()
|
defer stdout.Close()
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
container.Wait()
|
container.Wait()
|
||||||
@@ -1052,6 +959,7 @@ func TestEnv(t *testing.T) {
|
|||||||
goodEnv := []string{
|
goodEnv := []string{
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
"HOME=/",
|
"HOME=/",
|
||||||
|
"container=lxc",
|
||||||
}
|
}
|
||||||
sort.Strings(goodEnv)
|
sort.Strings(goodEnv)
|
||||||
if len(goodEnv) != len(actualEnv) {
|
if len(goodEnv) != len(actualEnv) {
|
||||||
@@ -1064,6 +972,29 @@ func TestEnv(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEntrypoint(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
container, err := NewBuilder(runtime).Create(
|
||||||
|
&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Entrypoint: []string{"/bin/echo"},
|
||||||
|
Cmd: []string{"-n", "foobar"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
output, err := container.Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if string(output) != "foobar" {
|
||||||
|
t.Error(string(output))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func grepFile(t *testing.T, path string, pattern string) {
|
func grepFile(t *testing.T, path string, pattern string) {
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1085,10 +1016,7 @@ func grepFile(t *testing.T, path string, pattern string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLXCConfig(t *testing.T) {
|
func TestLXCConfig(t *testing.T) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(t)
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
// Memory is allocated randomly for testing
|
// Memory is allocated randomly for testing
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
@@ -1121,10 +1049,7 @@ func TestLXCConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkRunSequencial(b *testing.B) {
|
func BenchmarkRunSequencial(b *testing.B) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(b)
|
||||||
if err != nil {
|
|
||||||
b.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
@@ -1150,10 +1075,7 @@ func BenchmarkRunSequencial(b *testing.B) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkRunParallel(b *testing.B) {
|
func BenchmarkRunParallel(b *testing.B) {
|
||||||
runtime, err := newTestRuntime()
|
runtime := mkRuntime(b)
|
||||||
if err != nil {
|
|
||||||
b.Fatal(err)
|
|
||||||
}
|
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
var tasks []chan error
|
var tasks []chan error
|
||||||
@@ -1172,7 +1094,8 @@ func BenchmarkRunParallel(b *testing.B) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
if err := container.Start(); err != nil {
|
hostConfig := &HostConfig{}
|
||||||
|
if err := container.Start(hostConfig); err != nil {
|
||||||
complete <- err
|
complete <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1201,3 +1124,169 @@ func BenchmarkRunParallel(b *testing.B) {
|
|||||||
b.Fatal(errors)
|
b.Fatal(errors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tempDir(t *testing.T) string {
|
||||||
|
tmpDir, err := ioutil.TempDir("", "docker-test")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return tmpDir
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBindMounts(t *testing.T) {
|
||||||
|
r := mkRuntime(t)
|
||||||
|
defer nuke(r)
|
||||||
|
tmpDir := tempDir(t)
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
writeFile(path.Join(tmpDir, "touch-me"), "", t)
|
||||||
|
|
||||||
|
// Test reading from a read-only bind mount
|
||||||
|
stdout, _ := runContainer(r, []string{"-v", fmt.Sprintf("%s:/tmp:ro", tmpDir), "_", "ls", "/tmp"}, t)
|
||||||
|
if !strings.Contains(stdout, "touch-me") {
|
||||||
|
t.Fatal("Container failed to read from bind mount")
|
||||||
|
}
|
||||||
|
|
||||||
|
// test writing to bind mount
|
||||||
|
runContainer(r, []string{"-v", fmt.Sprintf("%s:/tmp:rw", tmpDir), "_", "touch", "/tmp/holla"}, t)
|
||||||
|
readFile(path.Join(tmpDir, "holla"), t) // Will fail if the file doesn't exist
|
||||||
|
|
||||||
|
// test mounting to an illegal destination directory
|
||||||
|
if _, err := runContainer(r, []string{"-v", fmt.Sprintf("%s:.", tmpDir), "ls", "."}, nil); err == nil {
|
||||||
|
t.Fatal("Container bind mounted illegal directory")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that VolumesRW values are copied to the new container. Regression test for #1201
|
||||||
|
func TestVolumesFromReadonlyMount(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
container, err := NewBuilder(runtime).Create(
|
||||||
|
&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"/bin/echo", "-n", "foobar"},
|
||||||
|
Volumes: map[string]struct{}{"/test": {}},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
_, err = container.Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !container.VolumesRW["/test"] {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
container2, err := NewBuilder(runtime).Create(
|
||||||
|
&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"/bin/echo", "-n", "foobar"},
|
||||||
|
VolumesFrom: container.ID,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container2)
|
||||||
|
|
||||||
|
_, err = container2.Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if container.Volumes["/test"] != container2.Volumes["/test"] {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
actual, exists := container2.VolumesRW["/test"]
|
||||||
|
if !exists {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
if container.VolumesRW["/test"] != actual {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that restarting a container with a volume does not create a new volume on restart. Regression test for #819.
|
||||||
|
func TestRestartWithVolumes(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
|
Image: GetTestImage(runtime).ID,
|
||||||
|
Cmd: []string{"echo", "-n", "foobar"},
|
||||||
|
Volumes: map[string]struct{}{"/test": {}},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer runtime.Destroy(container)
|
||||||
|
|
||||||
|
for key := range container.Config.Volumes {
|
||||||
|
if key != "/test" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = container.Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := container.Volumes["/test"]
|
||||||
|
if expected == "" {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
// Run the container again to verify the volume path persists
|
||||||
|
_, err = container.Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := container.Volumes["/test"]
|
||||||
|
if expected != actual {
|
||||||
|
t.Fatalf("Expected volume path: %s Actual path: %s", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOnlyLoopbackExistsWhenUsingDisableNetworkOption(t *testing.T) {
|
||||||
|
runtime := mkRuntime(t)
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
config, hc, _, err := ParseRun([]string{"-n=false", GetTestImage(runtime).ID, "ip", "addr", "show"}, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
c, err := NewBuilder(runtime).Create(config)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
stdout, err := c.StdoutPipe()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer runtime.Destroy(c)
|
||||||
|
if err := c.Start(hc); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
c.WaitTimeout(500 * time.Millisecond)
|
||||||
|
c.Wait()
|
||||||
|
output, err := ioutil.ReadAll(stdout)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaces := regexp.MustCompile(`(?m)^[0-9]+: [a-zA-Z0-9]+`).FindAllString(string(output), -1)
|
||||||
|
if len(interfaces) != 1 {
|
||||||
|
t.Fatalf("Wrong interface count in test container: expected [1: lo], got [%s]", interfaces)
|
||||||
|
}
|
||||||
|
if interfaces[0] != "1: lo" {
|
||||||
|
t.Fatalf("Wrong interface in test container: expected [1: lo], got [%s]", interfaces)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ func crashTest() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
echo "Ensuring basic dependencies are installed..."
|
echo "Ensuring basic dependencies are installed..."
|
||||||
apt-get -qq update
|
apt-get -qq update
|
||||||
apt-get -qq install lxc wget bsdtar
|
apt-get -qq install lxc wget
|
||||||
|
|
||||||
echo "Looking in /proc/filesystems to see if we have AUFS support..."
|
echo "Looking in /proc/filesystems to see if we have AUFS support..."
|
||||||
if grep -q aufs /proc/filesystems
|
if grep -q aufs /proc/filesystems
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Generate a very minimal filesystem based on busybox-static,
|
||||||
|
# and load it into the local docker under the name "docker-ut".
|
||||||
|
|
||||||
|
missing_pkg() {
|
||||||
|
echo "Sorry, I could not locate $1"
|
||||||
|
echo "Try 'apt-get install ${2:-$1}'?"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
BUSYBOX=$(which busybox)
|
||||||
|
[ "$BUSYBOX" ] || missing_pkg busybox busybox-static
|
||||||
|
SOCAT=$(which socat)
|
||||||
|
[ "$SOCAT" ] || missing_pkg socat
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
set -ex
|
||||||
|
ROOTFS=`mktemp -d /tmp/rootfs-busybox.XXXXXXXXXX`
|
||||||
|
trap "rm -rf $ROOTFS" INT QUIT TERM
|
||||||
|
cd $ROOTFS
|
||||||
|
|
||||||
|
mkdir bin etc dev dev/pts lib proc sys tmp
|
||||||
|
touch etc/resolv.conf
|
||||||
|
cp /etc/nsswitch.conf etc/nsswitch.conf
|
||||||
|
echo root:x:0:0:root:/:/bin/sh > etc/passwd
|
||||||
|
echo daemon:x:1:1:daemon:/usr/sbin:/bin/sh >> etc/passwd
|
||||||
|
echo root:x:0: > etc/group
|
||||||
|
echo daemon:x:1: >> etc/group
|
||||||
|
ln -s lib lib64
|
||||||
|
ln -s bin sbin
|
||||||
|
cp $BUSYBOX $SOCAT bin
|
||||||
|
for X in $(busybox --list)
|
||||||
|
do
|
||||||
|
ln -s busybox bin/$X
|
||||||
|
done
|
||||||
|
rm bin/init
|
||||||
|
ln bin/busybox bin/init
|
||||||
|
cp -P /lib/x86_64-linux-gnu/lib{pthread*,c*(-*),dl*(-*),nsl*(-*),nss_*,util*(-*),wrap,z}.so* lib
|
||||||
|
cp /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 lib
|
||||||
|
cp -P /usr/lib/x86_64-linux-gnu/lib{crypto,ssl}.so* lib
|
||||||
|
for X in console null ptmx random stdin stdout stderr tty urandom zero
|
||||||
|
do
|
||||||
|
cp -a /dev/$X dev
|
||||||
|
done
|
||||||
|
|
||||||
|
chmod 0755 $ROOTFS # See #486
|
||||||
|
tar -cf- . | docker import - docker-ut
|
||||||
|
docker run -i -u root docker-ut /bin/echo Success.
|
||||||
|
rm -rf $ROOTFS
|
||||||
@@ -24,40 +24,30 @@ func main() {
|
|||||||
docker.SysInit()
|
docker.SysInit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
host := "127.0.0.1"
|
|
||||||
port := 4243
|
|
||||||
// FIXME: Switch d and D ? (to be more sshd like)
|
// FIXME: Switch d and D ? (to be more sshd like)
|
||||||
flDaemon := flag.Bool("d", false, "Daemon mode")
|
flDaemon := flag.Bool("d", false, "Daemon mode")
|
||||||
flDebug := flag.Bool("D", false, "Debug mode")
|
flDebug := flag.Bool("D", false, "Debug mode")
|
||||||
flAutoRestart := flag.Bool("r", false, "Restart previously running containers")
|
flAutoRestart := flag.Bool("r", false, "Restart previously running containers")
|
||||||
bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
|
bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge. Use 'none' to disable container networking")
|
||||||
pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
|
pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
|
||||||
flHost := flag.String("H", fmt.Sprintf("%s:%d", host, port), "Host:port to bind/connect to")
|
flGraphPath := flag.String("g", "/var/lib/docker", "Path to graph storage base dir.")
|
||||||
flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
|
flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
|
||||||
flDns := flag.String("dns", "", "Set custom dns servers")
|
flDns := flag.String("dns", "", "Set custom dns servers")
|
||||||
|
flHosts := docker.ListOpts{fmt.Sprintf("unix://%s", docker.DEFAULTUNIXSOCKET)}
|
||||||
|
flag.Var(&flHosts, "H", "tcp://host:port to bind/connect to or unix://path/to/socket to use")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
if len(flHosts) > 1 {
|
||||||
|
flHosts = flHosts[1:] //trick to display a nice defaul value in the usage
|
||||||
|
}
|
||||||
|
for i, flHost := range flHosts {
|
||||||
|
flHosts[i] = utils.ParseHost(docker.DEFAULTHTTPHOST, docker.DEFAULTHTTPPORT, flHost)
|
||||||
|
}
|
||||||
|
|
||||||
if *bridgeName != "" {
|
if *bridgeName != "" {
|
||||||
docker.NetworkBridgeIface = *bridgeName
|
docker.NetworkBridgeIface = *bridgeName
|
||||||
} else {
|
} else {
|
||||||
docker.NetworkBridgeIface = docker.DefaultNetworkBridge
|
docker.NetworkBridgeIface = docker.DefaultNetworkBridge
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(*flHost, ":") {
|
|
||||||
hostParts := strings.Split(*flHost, ":")
|
|
||||||
if len(hostParts) != 2 {
|
|
||||||
log.Fatal("Invalid bind address format.")
|
|
||||||
os.Exit(-1)
|
|
||||||
}
|
|
||||||
if hostParts[0] != "" {
|
|
||||||
host = hostParts[0]
|
|
||||||
}
|
|
||||||
if p, err := strconv.Atoi(hostParts[1]); err == nil {
|
|
||||||
port = p
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
host = *flHost
|
|
||||||
}
|
|
||||||
|
|
||||||
if *flDebug {
|
if *flDebug {
|
||||||
os.Setenv("DEBUG", "1")
|
os.Setenv("DEBUG", "1")
|
||||||
}
|
}
|
||||||
@@ -67,12 +57,17 @@ func main() {
|
|||||||
flag.Usage()
|
flag.Usage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := daemon(*pidfile, host, port, *flAutoRestart, *flEnableCors, *flDns); err != nil {
|
if err := daemon(*pidfile, *flGraphPath, flHosts, *flAutoRestart, *flEnableCors, *flDns); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := docker.ParseCommands(host, port, flag.Args()...); err != nil {
|
if len(flHosts) > 1 {
|
||||||
|
log.Fatal("Please specify only one -H")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
protoAddrParts := strings.SplitN(flHosts[0], "://", 2)
|
||||||
|
if err := docker.ParseCommands(protoAddrParts[0], protoAddrParts[1], flag.Args()...); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
@@ -106,10 +101,7 @@ func removePidFile(pidfile string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func daemon(pidfile, addr string, port int, autoRestart, enableCors bool, flDns string) error {
|
func daemon(pidfile string, flGraphPath string, protoAddrs []string, autoRestart, enableCors bool, flDns string) error {
|
||||||
if addr != "127.0.0.1" {
|
|
||||||
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
|
||||||
}
|
|
||||||
if err := createPidFile(pidfile); err != nil {
|
if err := createPidFile(pidfile); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -127,10 +119,32 @@ func daemon(pidfile, addr string, port int, autoRestart, enableCors bool, flDns
|
|||||||
if flDns != "" {
|
if flDns != "" {
|
||||||
dns = []string{flDns}
|
dns = []string{flDns}
|
||||||
}
|
}
|
||||||
server, err := docker.NewServer(autoRestart, enableCors, dns)
|
server, err := docker.NewServer(flGraphPath, autoRestart, enableCors, dns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
chErrors := make(chan error, len(protoAddrs))
|
||||||
return docker.ListenAndServe(fmt.Sprintf("%s:%d", addr, port), server, true)
|
for _, protoAddr := range protoAddrs {
|
||||||
|
protoAddrParts := strings.SplitN(protoAddr, "://", 2)
|
||||||
|
if protoAddrParts[0] == "unix" {
|
||||||
|
syscall.Unlink(protoAddrParts[1])
|
||||||
|
} else if protoAddrParts[0] == "tcp" {
|
||||||
|
if !strings.HasPrefix(protoAddrParts[1], "127.0.0.1") {
|
||||||
|
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Fatal("Invalid protocol format.")
|
||||||
|
os.Exit(-1)
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
chErrors <- docker.ListenAndServe(protoAddrParts[0], protoAddrParts[1], server, true)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
for i := 0; i < len(protoAddrs); i += 1 {
|
||||||
|
err := <-chErrors
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
:description: API Documentation for Docker
|
:description: API Documentation for Docker
|
||||||
:keywords: API, Docker, rcli, REST, documentation
|
:keywords: API, Docker, rcli, REST, documentation
|
||||||
|
|
||||||
|
.. COMMENT use http://pythonhosted.org/sphinxcontrib-httpdomain/ to
|
||||||
|
.. document the REST API.
|
||||||
|
|
||||||
=================
|
=================
|
||||||
Docker Remote API
|
Docker Remote API
|
||||||
=================
|
=================
|
||||||
@@ -12,31 +15,100 @@ Docker Remote API
|
|||||||
=====================
|
=====================
|
||||||
|
|
||||||
- The Remote API is replacing rcli
|
- The Remote API is replacing rcli
|
||||||
- Default port in the docker deamon is 4243
|
- By default the Docker daemon listens on unix:///var/run/docker.sock and the client must have root access to interact with the daemon
|
||||||
- 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
|
- The API tends to be REST, but for some complex commands, like attach
|
||||||
- Since API version 1.2, the auth configuration is now handled client side, so the client has to send the authConfig as POST in /images/(name)/push
|
or pull, the HTTP connection is hijacked to transport stdout stdin
|
||||||
|
and stderr
|
||||||
|
- Since API version 1.2, the auth configuration is now handled client
|
||||||
|
side, so the client has to send the authConfig as POST in
|
||||||
|
/images/(name)/push
|
||||||
|
|
||||||
2. Versions
|
2. Versions
|
||||||
===========
|
===========
|
||||||
|
|
||||||
The current verson of the API is 1.2
|
The current verson of the API is 1.4
|
||||||
Calling /images/<name>/insert is the same as calling /v1.2/images/<name>/insert
|
|
||||||
You can still call an old version of the api using /v1.0/images/<name>/insert
|
|
||||||
|
|
||||||
:doc:`docker_remote_api_v1.2`
|
Calling /images/<name>/insert is the same as calling
|
||||||
|
/v1.4/images/<name>/insert
|
||||||
|
|
||||||
|
You can still call an old version of the api using
|
||||||
|
/v1.0/images/<name>/insert
|
||||||
|
|
||||||
|
:doc:`docker_remote_api_v1.4`
|
||||||
*****************************
|
*****************************
|
||||||
|
|
||||||
What's new
|
What's new
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
.. http:get:: /containers/(id)/top
|
||||||
|
|
||||||
|
**New!** You can now use ps args with docker top, like `docker top <container_id> aux`
|
||||||
|
|
||||||
|
:doc:`docker_remote_api_v1.3`
|
||||||
|
*****************************
|
||||||
|
|
||||||
|
docker v0.5.0 51f6c4a_
|
||||||
|
|
||||||
|
What's new
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. http:get:: /containers/(id)/top
|
||||||
|
|
||||||
|
List the processes running inside a container.
|
||||||
|
|
||||||
|
.. http:get:: /events:
|
||||||
|
|
||||||
|
**New!** Monitor docker's events via streaming or via polling
|
||||||
|
|
||||||
|
Builder (/build):
|
||||||
|
|
||||||
|
- Simplify the upload of the build context
|
||||||
|
- Simply stream a tarball instead of multipart upload with 4
|
||||||
|
intermediary buffers
|
||||||
|
- Simpler, less memory usage, less disk usage and faster
|
||||||
|
|
||||||
|
.. Warning::
|
||||||
|
|
||||||
|
The /build improvements are not reverse-compatible. Pre 1.3 clients
|
||||||
|
will break on /build.
|
||||||
|
|
||||||
|
List containers (/containers/json):
|
||||||
|
|
||||||
|
- You can use size=1 to get the size of the containers
|
||||||
|
|
||||||
|
Start containers (/containers/<id>/start):
|
||||||
|
|
||||||
|
- You can now pass host-specific configuration (e.g. bind mounts) in
|
||||||
|
the POST body for start calls
|
||||||
|
|
||||||
|
:doc:`docker_remote_api_v1.2`
|
||||||
|
*****************************
|
||||||
|
|
||||||
|
docker v0.4.2 2e7649b_
|
||||||
|
|
||||||
|
What's new
|
||||||
|
----------
|
||||||
|
|
||||||
The auth configuration is now handled by the client.
|
The auth configuration is now handled by the client.
|
||||||
The client should send it's authConfig as POST on each call of /images/(name)/push
|
|
||||||
|
|
||||||
.. http:get:: /auth is now deprecated
|
The client should send it's authConfig as POST on each call of
|
||||||
.. http:post:: /auth only checks the configuration but doesn't store it on the server
|
/images/(name)/push
|
||||||
|
|
||||||
Deleting an image is now improved, will only untag the image if it has chidrens and remove all the untagged parents if has any.
|
.. http:get:: /auth
|
||||||
.. http:post:: /images/<name>/delete now returns a JSON with the list of images deleted/untagged
|
|
||||||
|
**Deprecated.**
|
||||||
|
|
||||||
|
.. http:post:: /auth
|
||||||
|
|
||||||
|
Only checks the configuration but doesn't store it on the server
|
||||||
|
|
||||||
|
Deleting an image is now improved, will only untag the image if it
|
||||||
|
has chidren and remove all the untagged parents if has any.
|
||||||
|
|
||||||
|
.. http:post:: /images/<name>/delete
|
||||||
|
|
||||||
|
Now returns a JSON structure with the list of images
|
||||||
|
deleted/untagged.
|
||||||
|
|
||||||
|
|
||||||
:doc:`docker_remote_api_v1.1`
|
:doc:`docker_remote_api_v1.1`
|
||||||
@@ -51,7 +123,7 @@ What's new
|
|||||||
.. http:post:: /images/(name)/insert
|
.. http:post:: /images/(name)/insert
|
||||||
.. http:post:: /images/(name)/push
|
.. http:post:: /images/(name)/push
|
||||||
|
|
||||||
Uses json stream instead of HTML hijack, it looks like this:
|
Uses json stream instead of HTML hijack, it looks like this:
|
||||||
|
|
||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
@@ -64,6 +136,9 @@ Uses json stream instead of HTML hijack, it looks like this:
|
|||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
:doc:`docker_remote_api_v1.0`
|
||||||
|
*****************************
|
||||||
|
|
||||||
docker v0.3.4 8d73740_
|
docker v0.3.4 8d73740_
|
||||||
|
|
||||||
What's new
|
What's new
|
||||||
@@ -74,6 +149,8 @@ Initial version
|
|||||||
|
|
||||||
.. _a8ae398: https://github.com/dotcloud/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f
|
.. _a8ae398: https://github.com/dotcloud/docker/commit/a8ae398bf52e97148ee7bd0d5868de2e15bd297f
|
||||||
.. _8d73740: https://github.com/dotcloud/docker/commit/8d73740343778651c09160cde9661f5f387b36f4
|
.. _8d73740: https://github.com/dotcloud/docker/commit/8d73740343778651c09160cde9661f5f387b36f4
|
||||||
|
.. _2e7649b: https://github.com/dotcloud/docker/commit/2e7649beda7c820793bd46766cbc2cfeace7b168
|
||||||
|
.. _51f6c4a: https://github.com/dotcloud/docker/commit/51f6c4a7372450d164c61e0054daf0223ddbd909
|
||||||
|
|
||||||
==================================
|
==================================
|
||||||
Docker Remote API Client Libraries
|
Docker Remote API Client Libraries
|
||||||
@@ -93,8 +170,13 @@ and we will add the libraries here.
|
|||||||
+----------------------+----------------+--------------------------------------------+
|
+----------------------+----------------+--------------------------------------------+
|
||||||
| Ruby | docker-client | https://github.com/geku/docker-client |
|
| Ruby | docker-client | https://github.com/geku/docker-client |
|
||||||
+----------------------+----------------+--------------------------------------------+
|
+----------------------+----------------+--------------------------------------------+
|
||||||
|
| Ruby | docker-api | https://github.com/swipely/docker-api |
|
||||||
|
+----------------------+----------------+--------------------------------------------+
|
||||||
| Javascript | docker-js | https://github.com/dgoujard/docker-js |
|
| Javascript | docker-js | https://github.com/dgoujard/docker-js |
|
||||||
+----------------------+----------------+--------------------------------------------+
|
+----------------------+----------------+--------------------------------------------+
|
||||||
| Javascript (Angular) | dockerui | https://github.com/crosbymichael/dockerui |
|
| Javascript (Angular) | dockerui | https://github.com/crosbymichael/dockerui |
|
||||||
| **WebUI** | | |
|
| **WebUI** | | |
|
||||||
+----------------------+----------------+--------------------------------------------+
|
+----------------------+----------------+--------------------------------------------+
|
||||||
|
| Java | docker-java | https://github.com/kpelykh/docker-java |
|
||||||
|
+----------------------+----------------+--------------------------------------------+
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
.. use orphan to suppress "WARNING: document isn't included in any toctree"
|
||||||
|
.. per http://sphinx-doc.org/markup/misc.html#file-wide-metadata
|
||||||
|
|
||||||
|
:orphan:
|
||||||
|
|
||||||
:title: Remote API v1.0
|
:title: Remote API v1.0
|
||||||
:description: API Documentation for Docker
|
:description: API Documentation for Docker
|
||||||
:keywords: API, Docker, rcli, REST, documentation
|
:keywords: API, Docker, rcli, REST, documentation
|
||||||
@@ -300,8 +305,8 @@ Start a container
|
|||||||
:statuscode 500: server error
|
:statuscode 500: server error
|
||||||
|
|
||||||
|
|
||||||
Stop a contaier
|
Stop a container
|
||||||
***************
|
****************
|
||||||
|
|
||||||
.. http:post:: /containers/(id)/stop
|
.. http:post:: /containers/(id)/stop
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
.. use orphan to suppress "WARNING: document isn't included in any toctree"
|
||||||
|
.. per http://sphinx-doc.org/markup/misc.html#file-wide-metadata
|
||||||
|
|
||||||
|
:orphan:
|
||||||
|
|
||||||
:title: Remote API v1.1
|
:title: Remote API v1.1
|
||||||
:description: API Documentation for Docker
|
:description: API Documentation for Docker
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
.. use orphan to suppress "WARNING: document isn't included in any toctree"
|
||||||
|
.. per http://sphinx-doc.org/markup/misc.html#file-wide-metadata
|
||||||
|
|
||||||
|
:orphan:
|
||||||
|
|
||||||
:title: Remote API v1.2
|
:title: Remote API v1.2
|
||||||
:description: API Documentation for Docker
|
:description: API Documentation for Docker
|
||||||
:keywords: API, Docker, rcli, REST, documentation
|
:keywords: API, Docker, rcli, REST, documentation
|
||||||
@@ -691,6 +696,7 @@ Get the history of an image
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"Id":"b750fe79269d",
|
"Id":"b750fe79269d",
|
||||||
|
"Tag":["base:latest"],
|
||||||
"Created":1364102658,
|
"Created":1364102658,
|
||||||
"CreatedBy":"/bin/bash"
|
"CreatedBy":"/bin/bash"
|
||||||
},
|
},
|
||||||
@@ -846,7 +852,7 @@ Build an image from Dockerfile via stdin
|
|||||||
|
|
||||||
.. http:post:: /build
|
.. http:post:: /build
|
||||||
|
|
||||||
Build an image from Dockerfile via stdin
|
Build an image from Dockerfile
|
||||||
|
|
||||||
**Example request**:
|
**Example request**:
|
||||||
|
|
||||||
@@ -865,9 +871,12 @@ Build an image from Dockerfile via stdin
|
|||||||
{{ STREAM }}
|
{{ STREAM }}
|
||||||
|
|
||||||
:query t: tag to be applied to the resulting image in case of success
|
:query t: tag to be applied to the resulting image in case of success
|
||||||
|
:query remote: resource to fetch, as URI
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
:statuscode 500: server error
|
:statuscode 500: server error
|
||||||
|
|
||||||
|
{{ STREAM }} is the raw text output of the build command. It uses the HTTP Hijack method in order to stream.
|
||||||
|
|
||||||
|
|
||||||
Check auth configuration
|
Check auth configuration
|
||||||
************************
|
************************
|
||||||
@@ -894,9 +903,16 @@ Check auth configuration
|
|||||||
.. sourcecode:: http
|
.. sourcecode:: http
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"Status": "Login Succeeded"
|
||||||
|
}
|
||||||
|
|
||||||
:statuscode 200: no error
|
:statuscode 200: no error
|
||||||
:statuscode 204: no error
|
:statuscode 204: no error
|
||||||
|
:statuscode 401: unauthorized
|
||||||
|
:statuscode 403: forbidden
|
||||||
:statuscode 500: server error
|
:statuscode 500: server error
|
||||||
|
|
||||||
|
|
||||||
@@ -1026,5 +1042,5 @@ In this version of the API, /attach, uses hijacking to transport stdin, stdout a
|
|||||||
|
|
||||||
To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
|
To enable cross origin requests to the remote api add the flag "-api-enable-cors" when running docker in daemon mode.
|
||||||
|
|
||||||
docker -d -H="192.168.1.9:4243" -api-enable-cors
|
docker -d -H="tcp://192.168.1.9:4243" -api-enable-cors
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ User Register
|
|||||||
"username": "foobar"'}
|
"username": "foobar"'}
|
||||||
|
|
||||||
:jsonparameter email: valid email address, that needs to be confirmed
|
:jsonparameter email: valid email address, that needs to be confirmed
|
||||||
:jsonparameter username: min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
|
:jsonparameter username: min 4 character, max 30 characters, must match the regular expression [a-z0-9\_].
|
||||||
:jsonparameter password: min 5 characters
|
:jsonparameter password: min 5 characters
|
||||||
|
|
||||||
**Example Response**:
|
**Example Response**:
|
||||||
|
|||||||
@@ -367,7 +367,8 @@ POST /v1/users
|
|||||||
{"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
|
{"email": "sam@dotcloud.com", "password": "toto42", "username": "foobar"'}
|
||||||
|
|
||||||
**Validation**:
|
**Validation**:
|
||||||
- **username** : min 4 character, max 30 characters, must match the regular expression [a-z0-9_].
|
- **username**: min 4 character, max 30 characters, must match the regular
|
||||||
|
expression [a-z0-9\_].
|
||||||
- **password**: min 5 characters
|
- **password**: min 5 characters
|
||||||
|
|
||||||
**Valid**: return HTTP 200
|
**Valid**: return HTTP 200
|
||||||
@@ -566,4 +567,4 @@ Next request::
|
|||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
- 1.0 : May 6th 2013 : initial release
|
- 1.0 : May 6th 2013 : initial release
|
||||||
- 1.1 : June 1st 2013 : Added Delete Repository and way to handle new source namespace.
|
- 1.1 : June 1st 2013 : Added Delete Repository and way to handle new source namespace.
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ To list available commands, either run ``docker`` with no parameters or execute
|
|||||||
|
|
||||||
$ docker
|
$ docker
|
||||||
Usage: docker [OPTIONS] COMMAND [arg...]
|
Usage: docker [OPTIONS] COMMAND [arg...]
|
||||||
-H="127.0.0.1:4243": Host:port to bind/connect to
|
-H=[tcp://127.0.0.1:4243]: tcp://host:port to bind/connect to or unix://path/to/socket to use
|
||||||
|
|
||||||
A self-sufficient runtime for linux containers.
|
A self-sufficient runtime for linux containers.
|
||||||
|
|
||||||
@@ -52,5 +52,6 @@ Available Commands
|
|||||||
command/start
|
command/start
|
||||||
command/stop
|
command/stop
|
||||||
command/tag
|
command/tag
|
||||||
|
command/top
|
||||||
command/version
|
command/version
|
||||||
command/wait
|
command/wait
|
||||||
|
|||||||
@@ -8,9 +8,12 @@
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
Usage: docker build [OPTIONS] PATH | -
|
Usage: docker build [OPTIONS] PATH | URL | -
|
||||||
Build a new container image from the source code at PATH
|
Build a new container image from the source code at PATH
|
||||||
-t="": Tag to be applied to the resulting image in case of success.
|
-t="": Tag to be applied to the resulting image in case of success.
|
||||||
|
-q=false: Suppress verbose build output.
|
||||||
|
When a single Dockerfile is given as URL, then no context is set. When a git repository is set as URL, the repository is used as context
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
@@ -27,7 +30,15 @@ Examples
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
docker build -
|
docker build - < Dockerfile
|
||||||
|
|
||||||
| This will read a Dockerfile from Stdin without context. Due to the lack of a context, no contents of any local directory will be sent to the docker daemon.
|
| This will read a Dockerfile from Stdin without context. Due to the lack of a context, no contents of any local directory will be sent to the docker daemon.
|
||||||
| ADD doesn't work when running in this mode due to the absence of the context, thus having no source files to copy to the container.
|
| ADD doesn't work when running in this mode due to the absence of the context, thus having no source files to copy to the container.
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
docker build github.com/creack/docker-firefox
|
||||||
|
|
||||||
|
| This will clone the github repository and use it as context. The Dockerfile at the root of the repository is used as Dockerfile.
|
||||||
|
| Note that you can specify an arbitrary git repository by using the 'git://' schema.
|
||||||
|
|||||||
@@ -12,8 +12,9 @@
|
|||||||
|
|
||||||
Create a new filesystem image from the contents of a tarball
|
Create a new filesystem image from the contents of a tarball
|
||||||
|
|
||||||
At this time, the URL must start with ``http`` and point to a single file archive (.tar, .tar.gz, .bzip)
|
At this time, the URL must start with ``http`` and point to a single file archive
|
||||||
containing a root filesystem. If you would like to import from a local directory or archive,
|
(.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz)
|
||||||
|
containing a root filesystem. If you would like to import from a local directory or archive,
|
||||||
you can use the ``-`` parameter to take the data from standard in.
|
you can use the ``-`` parameter to take the data from standard in.
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
@@ -30,7 +31,7 @@ Import from a local file
|
|||||||
Import to docker via pipe and standard in
|
Import to docker via pipe and standard in
|
||||||
|
|
||||||
``$ cat exampleimage.tgz | docker import - exampleimagelocal``
|
``$ cat exampleimage.tgz | docker import - exampleimagelocal``
|
||||||
|
|
||||||
Import from a local directory
|
Import from a local directory
|
||||||
.............................
|
.............................
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
Usage: docker login
|
Usage: docker login [OPTIONS]
|
||||||
|
|
||||||
Register or Login to the docker registry server
|
Register or Login to the docker registry server
|
||||||
|
|
||||||
|
-e="": email
|
||||||
|
-p="": password
|
||||||
|
-u="": username
|
||||||
|
|||||||
@@ -10,4 +10,4 @@
|
|||||||
|
|
||||||
Usage: docker rm [OPTIONS] CONTAINER
|
Usage: docker rm [OPTIONS] CONTAINER
|
||||||
|
|
||||||
Remove a container
|
Remove one or more containers
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
Usage: docker rmimage [OPTIONS] IMAGE
|
Usage: docker rmi IMAGE [IMAGE...]
|
||||||
|
|
||||||
Remove an image
|
Remove one or more images
|
||||||
|
|||||||
@@ -8,20 +8,33 @@
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
Usage: docker run [OPTIONS] IMAGE COMMAND [ARG...]
|
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
|
||||||
|
|
||||||
Run a command in a new container
|
Run a command in a new container
|
||||||
|
|
||||||
-a=map[]: Attach to stdin, stdout or stderr.
|
-a=map[]: Attach to stdin, stdout or stderr.
|
||||||
-c=0: CPU shares (relative weight)
|
-c=0: CPU shares (relative weight)
|
||||||
-d=false: Detached mode: leave the container running in the background
|
-cidfile="": Write the container ID to the file
|
||||||
|
-d=false: Detached mode: Run container in the background, print new container id
|
||||||
-e=[]: Set environment variables
|
-e=[]: Set environment variables
|
||||||
-h="": Container host name
|
-h="": Container host name
|
||||||
-i=false: Keep stdin open even if not attached
|
-i=false: Keep stdin open even if not attached
|
||||||
-m=0: Memory limit (in bytes)
|
-m=0: Memory limit (in bytes)
|
||||||
|
-n=true: Enable networking for this container
|
||||||
-p=[]: Map a network port to the container
|
-p=[]: Map a network port to the container
|
||||||
-t=false: Allocate a pseudo-tty
|
-t=false: Allocate a pseudo-tty
|
||||||
-u="": Username or UID
|
-u="": Username or UID
|
||||||
-d=[]: Set custom dns servers for the container
|
-d=[]: Set custom dns servers for the container
|
||||||
-v=[]: Creates a new volume and mounts it at the specified path.
|
-v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "host-dir" is missing, then docker creates a new volume.
|
||||||
-volumes-from="": Mount all volumes from the given container.
|
-volumes-from="": Mount all volumes from the given container.
|
||||||
|
-entrypoint="": Overwrite the default entrypoint set by the image.
|
||||||
|
|
||||||
|
|
||||||
|
Examples
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
docker run -cidfile /tmp/docker_test.cid ubuntu echo "test"
|
||||||
|
|
||||||
|
| This will create a container and print "test" to the console. The cidfile flag makes docker attempt to create a new file and write the container ID to it. If the file exists already, docker will return an error. Docker will close this file when docker run exits.
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
Usage: docker stop [OPTIONS] NAME
|
Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
|
||||||
|
|
||||||
Stop a running container
|
Stop a running container
|
||||||
|
|
||||||
|
-t=10: Number of seconds to wait for the container to stop before killing it.
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
:title: Top Command
|
||||||
|
:description: Lookup the running processes of a container
|
||||||
|
:keywords: top, docker, container, documentation
|
||||||
|
|
||||||
|
=======================================================
|
||||||
|
``top`` -- Lookup the running processes of a container
|
||||||
|
=======================================================
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
Usage: docker top CONTAINER
|
||||||
|
|
||||||
|
Lookup the running processes of a container
|
||||||
@@ -37,5 +37,6 @@ Contents:
|
|||||||
start <command/start>
|
start <command/start>
|
||||||
stop <command/stop>
|
stop <command/stop>
|
||||||
tag <command/tag>
|
tag <command/tag>
|
||||||
|
top <command/top>
|
||||||
version <command/version>
|
version <command/version>
|
||||||
wait <command/wait>
|
wait <command/wait>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
:title: Introduction
|
|
||||||
:description: An introduction to docker and standard containers?
|
|
||||||
:keywords: containers, lxc, concepts, explanation, docker, documentation
|
|
||||||
|
|
||||||
|
|
||||||
:note: This version of the introduction is temporary, just to make sure we don't break the links from the website when the documentation is updated
|
|
||||||
|
|
||||||
This document has been moved to :ref:`introduction`, please update your bookmarks.
|
|
||||||
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -1,10 +1,10 @@
|
|||||||
:title: Concepts
|
:title: Overview
|
||||||
:description: -- todo: change me
|
:description: Docker documentation summary
|
||||||
:keywords: concepts, documentation, docker, containers
|
:keywords: concepts, documentation, docker, containers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Concepts
|
Overview
|
||||||
========
|
========
|
||||||
|
|
||||||
Contents:
|
Contents:
|
||||||
@@ -13,4 +13,4 @@ Contents:
|
|||||||
:maxdepth: 1
|
:maxdepth: 1
|
||||||
|
|
||||||
../index
|
../index
|
||||||
|
manifesto
|
||||||
|
|||||||
@@ -1,125 +0,0 @@
|
|||||||
:title: Introduction
|
|
||||||
:description: An introduction to docker and standard containers?
|
|
||||||
:keywords: containers, lxc, concepts, explanation
|
|
||||||
|
|
||||||
Introduction
|
|
||||||
============
|
|
||||||
|
|
||||||
Docker -- The Linux container runtime
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
Docker complements LXC with a high-level API which operates at the process level. It runs unix processes with strong guarantees of isolation and repeatability across servers.
|
|
||||||
|
|
||||||
Docker is a great building block for automating distributed systems: large-scale web deployments, database clusters, continuous deployment systems, private PaaS, service-oriented architectures, etc.
|
|
||||||
|
|
||||||
|
|
||||||
- **Heterogeneous payloads** Any combination of binaries, libraries, configuration files, scripts, virtualenvs, jars, gems, tarballs, you name it. No more juggling between domain-specific tools. Docker can deploy and run them all.
|
|
||||||
- **Any server** Docker can run on any x64 machine with a modern linux kernel - whether it's a laptop, a bare metal server or a VM. This makes it perfect for multi-cloud deployments.
|
|
||||||
- **Isolation** docker isolates processes from each other and from the underlying host, using lightweight containers.
|
|
||||||
- **Repeatability** Because containers are isolated in their own filesystem, they behave the same regardless of where, when, and alongside what they run.
|
|
||||||
|
|
||||||
.. image:: images/lego_docker.jpg
|
|
||||||
|
|
||||||
|
|
||||||
What is a Standard Container?
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Docker defines a unit of software delivery called a Standard Container. The goal of a Standard Container is to encapsulate a software component and all its dependencies in
|
|
||||||
a format that is self-describing and portable, so that any compliant runtime can run it without extra dependency, regardless of the underlying machine and the contents of the container.
|
|
||||||
|
|
||||||
The spec for Standard Containers is currently work in progress, but it is very straightforward. It mostly defines 1) an image format, 2) a set of standard operations, and 3) an execution environment.
|
|
||||||
|
|
||||||
A great analogy for this is the shipping container. Just like Standard Containers are a fundamental unit of software delivery, shipping containers (http://bricks.argz.com/ins/7823-1/12) are a fundamental unit of physical delivery.
|
|
||||||
|
|
||||||
Standard operations
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Just like shipping containers, Standard Containers define a set of STANDARD OPERATIONS. Shipping containers can be lifted, stacked, locked, loaded, unloaded and labelled. Similarly, standard containers can be started, stopped, copied, snapshotted, downloaded, uploaded and tagged.
|
|
||||||
|
|
||||||
|
|
||||||
Content-agnostic
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Just like shipping containers, Standard Containers are CONTENT-AGNOSTIC: all standard operations have the same effect regardless of the contents. A shipping container will be stacked in exactly the same way whether it contains Vietnamese powder coffee or spare Maserati parts. Similarly, Standard Containers are started or uploaded in the same way whether they contain a postgres database, a php application with its dependencies and application server, or Java build artifacts.
|
|
||||||
|
|
||||||
|
|
||||||
Infrastructure-agnostic
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be transported to thousands of facilities around the world, and manipulated by a wide variety of equipment. A shipping container can be packed in a factory in Ukraine, transported by truck to the nearest routing center, stacked onto a train, loaded into a German boat by an Australian-built crane, stored in a warehouse at a US facility, etc. Similarly, a standard container can be bundled on my laptop, uploaded to S3, downloaded, run and snapshotted by a build server at Equinix in Virginia, uploaded to 10 staging servers in a home-made Openstack cluster, then sent to 30 production instances across 3 EC2 regions.
|
|
||||||
|
|
||||||
|
|
||||||
Designed for automation
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Because they offer the same standard operations regardless of content and infrastructure, Standard Containers, just like their physical counterpart, are extremely well-suited for automation. In fact, you could say automation is their secret weapon.
|
|
||||||
|
|
||||||
Many things that once required time-consuming and error-prone human effort can now be programmed. Before shipping containers, a bag of powder coffee was hauled, dragged, dropped, rolled and stacked by 10 different people in 10 different locations by the time it reached its destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The process was slow, inefficient and cost a fortune - and was entirely different depending on the facility and the type of goods.
|
|
||||||
|
|
||||||
Similarly, before Standard Containers, by the time a software component ran in production, it had been individually built, configured, bundled, documented, patched, vendored, templated, tweaked and instrumented by 10 different people on 10 different computers. Builds failed, libraries conflicted, mirrors crashed, post-it notes were lost, logs were misplaced, cluster updates were half-broken. The process was slow, inefficient and cost a fortune - and was entirely different depending on the language and infrastructure provider.
|
|
||||||
|
|
||||||
|
|
||||||
Industrial-grade delivery
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
There are 17 million shipping containers in existence, packed with every physical good imaginable. Every single one of them can be loaded on the same boats, by the same cranes, in the same facilities, and sent anywhere in the World with incredible efficiency. It is embarrassing to think that a 30 ton shipment of coffee can safely travel half-way across the World in *less time* than it takes a software team to deliver its code from one datacenter to another sitting 10 miles away.
|
|
||||||
|
|
||||||
With Standard Containers we can put an end to that embarrassment, by making INDUSTRIAL-GRADE DELIVERY of software a reality.
|
|
||||||
|
|
||||||
|
|
||||||
Standard Container Specification
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
(TODO)
|
|
||||||
|
|
||||||
Image format
|
|
||||||
~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Standard operations
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
- Copy
|
|
||||||
- Run
|
|
||||||
- Stop
|
|
||||||
- Wait
|
|
||||||
- Commit
|
|
||||||
- Attach standard streams
|
|
||||||
- List filesystem changes
|
|
||||||
- ...
|
|
||||||
|
|
||||||
Execution environment
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Root filesystem
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Environment variables
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Process arguments
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Networking
|
|
||||||
^^^^^^^^^^
|
|
||||||
|
|
||||||
Process namespacing
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Resource limits
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Process monitoring
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Logging
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Signals
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Pseudo-terminal allocation
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Security
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
:title: Manifesto
|
||||||
|
:description: An overview of Docker and standard containers
|
||||||
|
:keywords: containers, lxc, concepts, explanation
|
||||||
|
|
||||||
|
.. _dockermanifesto:
|
||||||
|
|
||||||
|
Docker Manifesto
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Docker complements LXC with a high-level API which operates at the
|
||||||
|
process level. It runs unix processes with strong guarantees of
|
||||||
|
isolation and repeatability across servers.
|
||||||
|
|
||||||
|
Docker is a great building block for automating distributed systems:
|
||||||
|
large-scale web deployments, database clusters, continuous deployment
|
||||||
|
systems, private PaaS, service-oriented architectures, etc.
|
||||||
|
|
||||||
|
- **Heterogeneous payloads** Any combination of binaries, libraries,
|
||||||
|
configuration files, scripts, virtualenvs, jars, gems, tarballs, you
|
||||||
|
name it. No more juggling between domain-specific tools. Docker can
|
||||||
|
deploy and run them all.
|
||||||
|
- **Any server** Docker can run on any x64 machine with a modern linux
|
||||||
|
kernel - whether it's a laptop, a bare metal server or a VM. This
|
||||||
|
makes it perfect for multi-cloud deployments.
|
||||||
|
- **Isolation** docker isolates processes from each other and from the
|
||||||
|
underlying host, using lightweight containers.
|
||||||
|
- **Repeatability** Because containers are isolated in their own
|
||||||
|
filesystem, they behave the same regardless of where, when, and
|
||||||
|
alongside what they run.
|
||||||
|
|
||||||
|
.. image:: images/lego_docker.jpg
|
||||||
|
:target: http://bricks.argz.com/ins/7823-1/12
|
||||||
|
|
||||||
|
What is a Standard Container?
|
||||||
|
.............................
|
||||||
|
|
||||||
|
Docker defines a unit of software delivery called a Standard
|
||||||
|
Container. The goal of a Standard Container is to encapsulate a
|
||||||
|
software component and all its dependencies in a format that is
|
||||||
|
self-describing and portable, so that any compliant runtime can run it
|
||||||
|
without extra dependency, regardless of the underlying machine and the
|
||||||
|
contents of the container.
|
||||||
|
|
||||||
|
The spec for Standard Containers is currently work in progress, but it
|
||||||
|
is very straightforward. It mostly defines 1) an image format, 2) a
|
||||||
|
set of standard operations, and 3) an execution environment.
|
||||||
|
|
||||||
|
A great analogy for this is the shipping container. Just like Standard
|
||||||
|
Containers are a fundamental unit of software delivery, shipping
|
||||||
|
containers are a fundamental unit of physical delivery.
|
||||||
|
|
||||||
|
Standard operations
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Just like shipping containers, Standard Containers define a set of
|
||||||
|
STANDARD OPERATIONS. Shipping containers can be lifted, stacked,
|
||||||
|
locked, loaded, unloaded and labelled. Similarly, standard containers
|
||||||
|
can be started, stopped, copied, snapshotted, downloaded, uploaded and
|
||||||
|
tagged.
|
||||||
|
|
||||||
|
|
||||||
|
Content-agnostic
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Just like shipping containers, Standard Containers are
|
||||||
|
CONTENT-AGNOSTIC: all standard operations have the same effect
|
||||||
|
regardless of the contents. A shipping container will be stacked in
|
||||||
|
exactly the same way whether it contains Vietnamese powder coffee or
|
||||||
|
spare Maserati parts. Similarly, Standard Containers are started or
|
||||||
|
uploaded in the same way whether they contain a postgres database, a
|
||||||
|
php application with its dependencies and application server, or Java
|
||||||
|
build artifacts.
|
||||||
|
|
||||||
|
Infrastructure-agnostic
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be
|
||||||
|
transported to thousands of facilities around the world, and
|
||||||
|
manipulated by a wide variety of equipment. A shipping container can
|
||||||
|
be packed in a factory in Ukraine, transported by truck to the nearest
|
||||||
|
routing center, stacked onto a train, loaded into a German boat by an
|
||||||
|
Australian-built crane, stored in a warehouse at a US facility,
|
||||||
|
etc. Similarly, a standard container can be bundled on my laptop,
|
||||||
|
uploaded to S3, downloaded, run and snapshotted by a build server at
|
||||||
|
Equinix in Virginia, uploaded to 10 staging servers in a home-made
|
||||||
|
Openstack cluster, then sent to 30 production instances across 3 EC2
|
||||||
|
regions.
|
||||||
|
|
||||||
|
|
||||||
|
Designed for automation
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Because they offer the same standard operations regardless of content
|
||||||
|
and infrastructure, Standard Containers, just like their physical
|
||||||
|
counterpart, are extremely well-suited for automation. In fact, you
|
||||||
|
could say automation is their secret weapon.
|
||||||
|
|
||||||
|
Many things that once required time-consuming and error-prone human
|
||||||
|
effort can now be programmed. Before shipping containers, a bag of
|
||||||
|
powder coffee was hauled, dragged, dropped, rolled and stacked by 10
|
||||||
|
different people in 10 different locations by the time it reached its
|
||||||
|
destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The
|
||||||
|
process was slow, inefficient and cost a fortune - and was entirely
|
||||||
|
different depending on the facility and the type of goods.
|
||||||
|
|
||||||
|
Similarly, before Standard Containers, by the time a software
|
||||||
|
component ran in production, it had been individually built,
|
||||||
|
configured, bundled, documented, patched, vendored, templated, tweaked
|
||||||
|
and instrumented by 10 different people on 10 different
|
||||||
|
computers. Builds failed, libraries conflicted, mirrors crashed,
|
||||||
|
post-it notes were lost, logs were misplaced, cluster updates were
|
||||||
|
half-broken. The process was slow, inefficient and cost a fortune -
|
||||||
|
and was entirely different depending on the language and
|
||||||
|
infrastructure provider.
|
||||||
|
|
||||||
|
Industrial-grade delivery
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
There are 17 million shipping containers in existence, packed with
|
||||||
|
every physical good imaginable. Every single one of them can be loaded
|
||||||
|
on the same boats, by the same cranes, in the same facilities, and
|
||||||
|
sent anywhere in the World with incredible efficiency. It is
|
||||||
|
embarrassing to think that a 30 ton shipment of coffee can safely
|
||||||
|
travel half-way across the World in *less time* than it takes a
|
||||||
|
software team to deliver its code from one datacenter to another
|
||||||
|
sitting 10 miles away.
|
||||||
|
|
||||||
|
With Standard Containers we can put an end to that embarrassment, by
|
||||||
|
making INDUSTRIAL-GRADE DELIVERY of software a reality.
|
||||||
@@ -20,6 +20,21 @@ import sys, os
|
|||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
# -- General configuration -----------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Additional templates that should be rendered to pages, maps page names to
|
||||||
|
# template names.
|
||||||
|
# the 'redirect_home.html' page redirects using a http meta refresh which, according
|
||||||
|
# to official sources is more or less equivalent of a 301.
|
||||||
|
|
||||||
|
html_additional_pages = {
|
||||||
|
'concepts/containers': 'redirect_home.html',
|
||||||
|
'concepts/introduction': 'redirect_home.html',
|
||||||
|
'builder/basics': 'redirect_build.html',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
# If your documentation needs a minimal Sphinx version, state it here.
|
||||||
#needs_sphinx = '1.0'
|
#needs_sphinx = '1.0'
|
||||||
|
|
||||||
@@ -120,7 +135,11 @@ html_theme_path = ['../theme']
|
|||||||
# The name of an image file (within the static path) to use as favicon of the
|
# The name of an image file (within the static path) to use as favicon of the
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||||
# pixels large.
|
# pixels large.
|
||||||
#html_favicon = None
|
|
||||||
|
# We use a png favicon. This is not compatible with internet explorer, but looks
|
||||||
|
# much better on all other browsers. However, sphynx doesn't like it (it likes
|
||||||
|
# .ico better) so we have just put it in the template rather than used this setting
|
||||||
|
# html_favicon = 'favicon.png'
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
@@ -138,10 +157,6 @@ html_static_path = ['static_files']
|
|||||||
# Custom sidebar templates, maps document names to template names.
|
# Custom sidebar templates, maps document names to template names.
|
||||||
#html_sidebars = {}
|
#html_sidebars = {}
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
|
||||||
# template names.
|
|
||||||
#html_additional_pages = {}
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
# If false, no module index is generated.
|
||||||
#html_domain_indices = True
|
#html_domain_indices = True
|
||||||
|
|
||||||
|
|||||||
@@ -5,53 +5,54 @@
|
|||||||
Setting Up a Dev Environment
|
Setting Up a Dev Environment
|
||||||
============================
|
============================
|
||||||
|
|
||||||
Instructions that have been verified to work on Ubuntu Precise 12.04 (LTS) (64-bit),
|
To make it easier to contribute to Docker, we provide a standard development environment. It is important that
|
||||||
|
the same environment be used for all tests, builds and releases. The standard development environment defines
|
||||||
|
all build dependencies: system libraries and binaries, go environment, go dependencies, etc.
|
||||||
|
|
||||||
|
|
||||||
Dependencies
|
Step 1: install docker
|
||||||
------------
|
----------------------
|
||||||
|
|
||||||
**Linux kernel 3.8**
|
Docker's build environment itself is a docker container, so the first step is to install docker on your system.
|
||||||
|
|
||||||
Due to a bug in LXC docker works best on the 3.8 kernel. Precise comes with a 3.2 kernel, so we need to upgrade it. The kernel we install comes with AUFS built in.
|
You can follow the `install instructions most relevant to your system <https://docs.docker.io/en/latest/installation/>`.
|
||||||
|
Make sure you have a working, up-to-date docker installation, then continue to the next step.
|
||||||
|
|
||||||
|
|
||||||
.. code-block:: bash
|
Step 2: check out the source
|
||||||
|
----------------------------
|
||||||
|
|
||||||
# install the backported kernel
|
::
|
||||||
sudo apt-get update && sudo apt-get install linux-image-generic-lts-raring
|
|
||||||
|
|
||||||
# reboot
|
git clone http://git@github.com/dotcloud/docker
|
||||||
sudo reboot
|
|
||||||
|
|
||||||
|
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
sudo apt-get install python-software-properties
|
|
||||||
sudo add-apt-repository ppa:gophers/go
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y install lxc wget bsdtar curl golang-stable git aufs-tools
|
|
||||||
|
|
||||||
export GOPATH=~/go/
|
|
||||||
export PATH=$GOPATH/bin:$PATH
|
|
||||||
|
|
||||||
mkdir -p $GOPATH/src/github.com/dotcloud
|
|
||||||
cd $GOPATH/src/github.com/dotcloud
|
|
||||||
git clone git://github.com/dotcloud/docker.git
|
|
||||||
cd docker
|
cd docker
|
||||||
|
|
||||||
go get -v github.com/dotcloud/docker/...
|
|
||||||
go install -v github.com/dotcloud/docker/...
|
Step 3: build
|
||||||
|
-------------
|
||||||
|
|
||||||
|
When you are ready to build docker, run this command:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
docker build -t docker .
|
||||||
|
|
||||||
|
This will build the revision currently checked out in the repository. Feel free to check out the version
|
||||||
|
of your choice.
|
||||||
|
|
||||||
|
If the build is successful, congratulations! You have produced a clean build of docker, neatly encapsulated
|
||||||
|
in a standard build environment.
|
||||||
|
|
||||||
|
You can run an interactive session in the newly built container:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
docker run -i -t docker bash
|
||||||
|
|
||||||
|
|
||||||
Then run the docker daemon,
|
To extract the binaries from the container:
|
||||||
|
|
||||||
.. code-block:: bash
|
::
|
||||||
|
|
||||||
sudo $GOPATH/bin/docker -d
|
docker run docker sh -c 'cat $(which docker)' > docker-build && chmod +x docker-build
|
||||||
|
|
||||||
|
|
||||||
Run the ``go install`` command (above) to recompile docker.
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ This time, we're requesting shared access to $COUCH1's volumes.
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
COUCH2=$(docker run -d -volumes-from $COUCH1) shykes/couchdb:2013-05-03)
|
COUCH2=$(docker run -d -volumes-from $COUCH1 shykes/couchdb:2013-05-03)
|
||||||
|
|
||||||
Browse data on the second database
|
Browse data on the second database
|
||||||
----------------------------------
|
----------------------------------
|
||||||
@@ -48,6 +48,6 @@ Browse data on the second database
|
|||||||
|
|
||||||
HOST=localhost
|
HOST=localhost
|
||||||
URL="http://$HOST:$(docker port $COUCH2 5984)/_utils/"
|
URL="http://$HOST:$(docker port $COUCH2 5984)/_utils/"
|
||||||
echo "Navigate to $URL in your browser. You should see the same data as in the first database!"
|
echo "Navigate to $URL in your browser. You should see the same data as in the first database"'!'
|
||||||
|
|
||||||
Congratulations, you are running 2 Couchdb containers, completely isolated from each other *except* for their data.
|
Congratulations, you are running 2 Couchdb containers, completely isolated from each other *except* for their data.
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ Connect to the host os with the redis-cli.
|
|||||||
|
|
||||||
docker ps # grab the new container id
|
docker ps # grab the new container id
|
||||||
docker port <container_id> 6379 # grab the external port
|
docker port <container_id> 6379 # grab the external port
|
||||||
ifconfig # grab the host ip address
|
ip addr show # grab the host ip address
|
||||||
redis-cli -h <host ipaddress> -p <external port>
|
redis-cli -h <host ipaddress> -p <external port>
|
||||||
redis 192.168.0.1:49153> set docker awesome
|
redis 192.168.0.1:49153> set docker awesome
|
||||||
OK
|
OK
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ The password is 'screencast'
|
|||||||
# it has now given us a port to connect to
|
# it has now given us a port to connect to
|
||||||
# we have to connect using a public ip of our host
|
# we have to connect using a public ip of our host
|
||||||
$ hostname
|
$ hostname
|
||||||
|
# *ifconfig* is deprecated, better use *ip addr show* now
|
||||||
$ ifconfig
|
$ ifconfig
|
||||||
$ ssh root@192.168.33.10 -p 49153
|
$ ssh root@192.168.33.10 -p 49153
|
||||||
# Ah! forgot to set root passwd
|
# Ah! forgot to set root passwd
|
||||||
@@ -70,6 +71,7 @@ The password is 'screencast'
|
|||||||
$ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd
|
$ docker commit 9e863f0ca0af31c8b951048ba87641d67c382d08d655c2e4879c51410e0fedc1 dhrp/sshd
|
||||||
$ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D
|
$ docker run -d -p 22 dhrp/sshd /usr/sbin/sshd -D
|
||||||
$ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22
|
$ docker port a0aaa9558c90cf5c7782648df904a82365ebacce523e4acc085ac1213bfe2206 22
|
||||||
|
# *ifconfig* is deprecated, better use *ip addr show* now
|
||||||
$ ifconfig
|
$ ifconfig
|
||||||
$ ssh root@192.168.33.10 -p 49154
|
$ ssh root@192.168.33.10 -p 49154
|
||||||
# Thanks for watching, Thatcher thatcher@dotcloud.com
|
# Thanks for watching, Thatcher thatcher@dotcloud.com
|
||||||
|
|||||||
@@ -1,127 +1,36 @@
|
|||||||
:title: Introduction
|
:title: Welcome to the Docker Documentation
|
||||||
:description: An introduction to docker and standard containers?
|
:description: An overview of the Docker Documentation
|
||||||
:keywords: containers, lxc, concepts, explanation
|
:keywords: containers, lxc, concepts, explanation
|
||||||
|
|
||||||
.. _introduction:
|
Welcome
|
||||||
|
=======
|
||||||
|
|
||||||
Introduction
|
.. image:: concepts/images/dockerlogo-h.png
|
||||||
============
|
|
||||||
|
|
||||||
Docker -- The Linux container runtime
|
``docker``, the Linux Container Runtime, runs Unix processes with
|
||||||
-------------------------------------
|
strong guarantees of isolation across servers. Your software runs
|
||||||
|
repeatably everywhere because its :ref:`container_def` includes any
|
||||||
|
dependencies.
|
||||||
|
|
||||||
Docker complements LXC with a high-level API which operates at the process level. It runs unix processes with strong guarantees of isolation and repeatability across servers.
|
``docker`` runs three ways:
|
||||||
|
|
||||||
Docker is a great building block for automating distributed systems: large-scale web deployments, database clusters, continuous deployment systems, private PaaS, service-oriented architectures, etc.
|
* as a daemon to manage LXC containers on your :ref:`Linux host
|
||||||
|
<kernel>` (``sudo docker -d``)
|
||||||
|
* as a :ref:`CLI <cli>` which talks to the daemon's `REST API
|
||||||
|
<api/docker_remote_api>`_ (``docker run ...``)
|
||||||
|
* as a client of :ref:`Repositories <working_with_the_repository>`
|
||||||
|
that let you share what you've built (``docker pull, docker
|
||||||
|
commit``).
|
||||||
|
|
||||||
|
Each use of ``docker`` is documented here. The features of Docker are
|
||||||
|
currently in active development, so this documention will change
|
||||||
|
frequently.
|
||||||
|
|
||||||
- **Heterogeneous payloads** Any combination of binaries, libraries, configuration files, scripts, virtualenvs, jars, gems, tarballs, you name it. No more juggling between domain-specific tools. Docker can deploy and run them all.
|
For an overview of Docker, please see the `Introduction
|
||||||
- **Any server** Docker can run on any x64 machine with a modern linux kernel - whether it's a laptop, a bare metal server or a VM. This makes it perfect for multi-cloud deployments.
|
<http://www.docker.io>`_. When you're ready to start working with
|
||||||
- **Isolation** docker isolates processes from each other and from the underlying host, using lightweight containers.
|
Docker, we have a `quick start <http://www.docker.io/gettingstarted>`_
|
||||||
- **Repeatability** Because containers are isolated in their own filesystem, they behave the same regardless of where, when, and alongside what they run.
|
and a more in-depth guide to :ref:`ubuntu_linux` and other
|
||||||
|
:ref:`installation_list` paths including prebuilt binaries,
|
||||||
.. image:: concepts/images/lego_docker.jpg
|
Vagrant-created VMs, Rackspace and Amazon instances.
|
||||||
|
|
||||||
|
|
||||||
What is a Standard Container?
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Docker defines a unit of software delivery called a Standard Container. The goal of a Standard Container is to encapsulate a software component and all its dependencies in
|
|
||||||
a format that is self-describing and portable, so that any compliant runtime can run it without extra dependency, regardless of the underlying machine and the contents of the container.
|
|
||||||
|
|
||||||
The spec for Standard Containers is currently work in progress, but it is very straightforward. It mostly defines 1) an image format, 2) a set of standard operations, and 3) an execution environment.
|
|
||||||
|
|
||||||
A great analogy for this is the shipping container. Just like Standard Containers are a fundamental unit of software delivery, shipping containers (http://bricks.argz.com/ins/7823-1/12) are a fundamental unit of physical delivery.
|
|
||||||
|
|
||||||
Standard operations
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Just like shipping containers, Standard Containers define a set of STANDARD OPERATIONS. Shipping containers can be lifted, stacked, locked, loaded, unloaded and labelled. Similarly, standard containers can be started, stopped, copied, snapshotted, downloaded, uploaded and tagged.
|
|
||||||
|
|
||||||
|
|
||||||
Content-agnostic
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Just like shipping containers, Standard Containers are CONTENT-AGNOSTIC: all standard operations have the same effect regardless of the contents. A shipping container will be stacked in exactly the same way whether it contains Vietnamese powder coffee or spare Maserati parts. Similarly, Standard Containers are started or uploaded in the same way whether they contain a postgres database, a php application with its dependencies and application server, or Java build artifacts.
|
|
||||||
|
|
||||||
|
|
||||||
Infrastructure-agnostic
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Both types of containers are INFRASTRUCTURE-AGNOSTIC: they can be transported to thousands of facilities around the world, and manipulated by a wide variety of equipment. A shipping container can be packed in a factory in Ukraine, transported by truck to the nearest routing center, stacked onto a train, loaded into a German boat by an Australian-built crane, stored in a warehouse at a US facility, etc. Similarly, a standard container can be bundled on my laptop, uploaded to S3, downloaded, run and snapshotted by a build server at Equinix in Virginia, uploaded to 10 staging servers in a home-made Openstack cluster, then sent to 30 production instances across 3 EC2 regions.
|
|
||||||
|
|
||||||
|
|
||||||
Designed for automation
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Because they offer the same standard operations regardless of content and infrastructure, Standard Containers, just like their physical counterpart, are extremely well-suited for automation. In fact, you could say automation is their secret weapon.
|
|
||||||
|
|
||||||
Many things that once required time-consuming and error-prone human effort can now be programmed. Before shipping containers, a bag of powder coffee was hauled, dragged, dropped, rolled and stacked by 10 different people in 10 different locations by the time it reached its destination. 1 out of 50 disappeared. 1 out of 20 was damaged. The process was slow, inefficient and cost a fortune - and was entirely different depending on the facility and the type of goods.
|
|
||||||
|
|
||||||
Similarly, before Standard Containers, by the time a software component ran in production, it had been individually built, configured, bundled, documented, patched, vendored, templated, tweaked and instrumented by 10 different people on 10 different computers. Builds failed, libraries conflicted, mirrors crashed, post-it notes were lost, logs were misplaced, cluster updates were half-broken. The process was slow, inefficient and cost a fortune - and was entirely different depending on the language and infrastructure provider.
|
|
||||||
|
|
||||||
|
|
||||||
Industrial-grade delivery
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
There are 17 million shipping containers in existence, packed with every physical good imaginable. Every single one of them can be loaded on the same boats, by the same cranes, in the same facilities, and sent anywhere in the World with incredible efficiency. It is embarrassing to think that a 30 ton shipment of coffee can safely travel half-way across the World in *less time* than it takes a software team to deliver its code from one datacenter to another sitting 10 miles away.
|
|
||||||
|
|
||||||
With Standard Containers we can put an end to that embarrassment, by making INDUSTRIAL-GRADE DELIVERY of software a reality.
|
|
||||||
|
|
||||||
|
|
||||||
Standard Container Specification
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
(TODO)
|
|
||||||
|
|
||||||
Image format
|
|
||||||
~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Standard operations
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
- Copy
|
|
||||||
- Run
|
|
||||||
- Stop
|
|
||||||
- Wait
|
|
||||||
- Commit
|
|
||||||
- Attach standard streams
|
|
||||||
- List filesystem changes
|
|
||||||
- ...
|
|
||||||
|
|
||||||
Execution environment
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Root filesystem
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Environment variables
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Process arguments
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Networking
|
|
||||||
^^^^^^^^^^
|
|
||||||
|
|
||||||
Process namespacing
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Resource limits
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Process monitoring
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Logging
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Signals
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Pseudo-terminal allocation
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Security
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
|
Enough reading! :ref:`Try it out! <running_examples>`
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
:title: Index Environment Variable
|
|
||||||
:description: Setting this environment variable on the docker server will change the URL docker index.
|
|
||||||
:keywords: docker, index environment variable, documentation
|
|
||||||
|
|
||||||
=================================
|
|
||||||
Docker Index Environment Variable
|
|
||||||
=================================
|
|
||||||
|
|
||||||
Variable
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
DOCKER_INDEX_URL
|
|
||||||
|
|
||||||
Setting this environment variable on the docker server will change the URL docker index.
|
|
||||||
This address is used in commands such as ``docker login``, ``docker push`` and ``docker pull``.
|
|
||||||
The docker daemon doesn't need to be restarted for this parameter to take effect.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
docker -d &
|
|
||||||
export DOCKER_INDEX_URL="https://index.docker.io"
|
|
||||||
|
|
||||||
@@ -30,8 +30,7 @@ Dependencies:
|
|||||||
* 3.8 Kernel (read more about :ref:`kernel`)
|
* 3.8 Kernel (read more about :ref:`kernel`)
|
||||||
* AUFS filesystem support
|
* AUFS filesystem support
|
||||||
* lxc
|
* lxc
|
||||||
* bsdtar
|
* xz-utils
|
||||||
|
|
||||||
|
|
||||||
Get the docker binary:
|
Get the docker binary:
|
||||||
----------------------
|
----------------------
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
:title: Documentation
|
:title: Docker Installation
|
||||||
:description: -- todo: change me
|
:description: many ways to install Docker
|
||||||
:keywords: todo, docker, documentation, installation, OS support
|
:keywords: docker, installation
|
||||||
|
|
||||||
|
|
||||||
|
.. _installation_list:
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
|
There are a number of ways to install Docker, depending on where you
|
||||||
|
want to run the daemon. The :ref:`ubuntu_linux` installation is the
|
||||||
|
officially-tested version, and the community adds more techniques for
|
||||||
|
installing Docker all the time.
|
||||||
|
|
||||||
Contents:
|
Contents:
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ Memory and Swap Accounting on Debian/Ubuntu
|
|||||||
If you use Debian or Ubuntu kernels, and want to enable memory and swap
|
If you use Debian or Ubuntu kernels, and want to enable memory and swap
|
||||||
accounting, you must add the following command-line parameters to your kernel::
|
accounting, you must add the following command-line parameters to your kernel::
|
||||||
|
|
||||||
cgroup_enable=memory swapaccount
|
cgroup_enable=memory swapaccount=1
|
||||||
|
|
||||||
On Debian or Ubuntu systems, if you use the default GRUB bootloader, you can
|
On Debian or Ubuntu systems, if you use the default GRUB bootloader, you can
|
||||||
add those parameters by editing ``/etc/default/grub`` and extending
|
add those parameters by editing ``/etc/default/grub`` and extending
|
||||||
@@ -110,6 +110,6 @@ add those parameters by editing ``/etc/default/grub`` and extending
|
|||||||
|
|
||||||
And replace it by the following one::
|
And replace it by the following one::
|
||||||
|
|
||||||
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount"
|
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
|
||||||
|
|
||||||
Then run ``update-grub``, and reboot.
|
Then run ``update-grub``, and reboot.
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
:title: Container
|
||||||
|
:description: Definitions of a container
|
||||||
|
:keywords: containers, lxc, concepts, explanation, image, container
|
||||||
|
|
||||||
|
.. _container_def:
|
||||||
|
|
||||||
|
Container
|
||||||
|
=========
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-busyboxrw.png
|
||||||
|
|
||||||
|
Once you start a process in Docker from an :ref:`image_def`, Docker
|
||||||
|
fetches the image and its :ref:`parent_image_def`, and repeats the
|
||||||
|
process until it reaches the :ref:`base_image_def`. Then the
|
||||||
|
:ref:`ufs_def` adds a read-write layer on top. That read-write layer,
|
||||||
|
plus the information about its :ref:`parent_image_def` and some
|
||||||
|
additional information like its unique id, networking configuration,
|
||||||
|
and resource limits is called a **container**.
|
||||||
|
|
||||||
|
.. _container_state_def:
|
||||||
|
|
||||||
|
Container State
|
||||||
|
...............
|
||||||
|
|
||||||
|
Containers can change, and so they have state. A container may be
|
||||||
|
**running** or **exited**.
|
||||||
|
|
||||||
|
When a container is running, the idea of a "container" also includes a
|
||||||
|
tree of processes running on the CPU, isolated from the other
|
||||||
|
processes running on the host.
|
||||||
|
|
||||||
|
When the container is exited, the state of the file system and
|
||||||
|
its exit value is preserved. You can start, stop, and restart a
|
||||||
|
container. The processes restart from scratch (their memory state is
|
||||||
|
**not** preserved in a container), but the file system is just as it
|
||||||
|
was when the container was stopped.
|
||||||
|
|
||||||
|
You can promote a container to an :ref:`image_def` with ``docker
|
||||||
|
commit``. Once a container is an image, you can use it as a parent for
|
||||||
|
new containers.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
:title: File Systems
|
||||||
|
:description: How Linux organizes its persistent storage
|
||||||
|
:keywords: containers, files, linux
|
||||||
|
|
||||||
|
.. _filesystem_def:
|
||||||
|
|
||||||
|
File System
|
||||||
|
===========
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-generic.png
|
||||||
|
|
||||||
|
In order for a Linux system to run, it typically needs two `file
|
||||||
|
systems <http://en.wikipedia.org/wiki/Filesystem>`_:
|
||||||
|
|
||||||
|
1. boot file system (bootfs)
|
||||||
|
2. root file system (rootfs)
|
||||||
|
|
||||||
|
The **boot file system** contains the bootloader and the kernel. The
|
||||||
|
user never makes any changes to the boot file system. In fact, soon
|
||||||
|
after the boot process is complete, the entire kernel is in memory,
|
||||||
|
and the boot file system is unmounted to free up the RAM associated
|
||||||
|
with the initrd disk image.
|
||||||
|
|
||||||
|
|
||||||
|
The **root file system** includes the typical directory structure we
|
||||||
|
associate with Unix-like operating systems: ``/dev, /proc, /bin, /etc,
|
||||||
|
/lib, /usr,`` and ``/tmp`` plus all the configuration files, binaries
|
||||||
|
and libraries required to run user applications (like bash, ls, and so
|
||||||
|
forth).
|
||||||
|
|
||||||
|
While there can be important kernel differences between different
|
||||||
|
Linux distributions, the contents and organization of the root file
|
||||||
|
system are usually what make your software packages dependent on one
|
||||||
|
distribution versus another. Docker can help solve this problem by
|
||||||
|
running multiple distributions at the same time.
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-multiroot.png
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
:title: Images
|
||||||
|
:description: Definition of an image
|
||||||
|
:keywords: containers, lxc, concepts, explanation, image, container
|
||||||
|
|
||||||
|
.. _image_def:
|
||||||
|
|
||||||
|
Image
|
||||||
|
=====
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-debian.png
|
||||||
|
|
||||||
|
In Docker terminology, a read-only :ref:`layer_def` is called an
|
||||||
|
**image**. An image never changes.
|
||||||
|
|
||||||
|
Since Docker uses a :ref:`ufs_def`, the processes think the whole file
|
||||||
|
system is mounted read-write. But all the changes go to the top-most
|
||||||
|
writeable layer, and underneath, the original file in the read-only
|
||||||
|
image is unchanged. Since images don't change, images do not have state.
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-debianrw.png
|
||||||
|
|
||||||
|
.. _parent_image_def:
|
||||||
|
|
||||||
|
Parent Image
|
||||||
|
............
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-multilayer.png
|
||||||
|
|
||||||
|
Each image may depend on one more image which forms the layer beneath
|
||||||
|
it. We sometimes say that the lower image is the **parent** of the
|
||||||
|
upper image.
|
||||||
|
|
||||||
|
.. _base_image_def:
|
||||||
|
|
||||||
|
Base Image
|
||||||
|
..........
|
||||||
|
|
||||||
|
An image that has no parent is a **base image**.
|
||||||
|
After Width: | Height: | Size: 117 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 110 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 272 KiB |
@@ -0,0 +1,22 @@
|
|||||||
|
:title: Glossary
|
||||||
|
:description: Definitions of terms used in Docker documentation
|
||||||
|
:keywords: concepts, documentation, docker, containers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Glossary
|
||||||
|
========
|
||||||
|
|
||||||
|
Definitions of terms used in Docker documentation.
|
||||||
|
|
||||||
|
Contents:
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
filesystem
|
||||||
|
layer
|
||||||
|
image
|
||||||
|
container
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
:title: Layers
|
||||||
|
:description: Organizing the Docker Root File System
|
||||||
|
:keywords: containers, lxc, concepts, explanation, image, container
|
||||||
|
|
||||||
|
Layers
|
||||||
|
======
|
||||||
|
|
||||||
|
In a traditional Linux boot, the kernel first mounts the root
|
||||||
|
:ref:`filesystem_def` as read-only, checks its integrity, and then
|
||||||
|
switches the whole rootfs volume to read-write mode.
|
||||||
|
|
||||||
|
.. _layer_def:
|
||||||
|
|
||||||
|
Layer
|
||||||
|
.....
|
||||||
|
|
||||||
|
When Docker mounts the rootfs, it starts read-only, as in a tradtional
|
||||||
|
Linux boot, but then, instead of changing the file system to
|
||||||
|
read-write mode, it takes advantage of a `union mount
|
||||||
|
<http://en.wikipedia.org/wiki/Union_mount>`_ to add a read-write file
|
||||||
|
system *over* the read-only file system. In fact there may be multiple
|
||||||
|
read-only file systems stacked on top of each other. We think of each
|
||||||
|
one of these file systems as a **layer**.
|
||||||
|
|
||||||
|
.. image:: images/docker-filesystems-multilayer.png
|
||||||
|
|
||||||
|
At first, the top read-write layer has nothing in it, but any time a
|
||||||
|
process creates a file, this happens in the top layer. And if
|
||||||
|
something needs to update an existing file in a lower layer, then the
|
||||||
|
file gets copied to the upper layer and changes go into the copy. The
|
||||||
|
version of the file on the lower layer cannot be seen by the
|
||||||
|
applications anymore, but it is there, unchanged.
|
||||||
|
|
||||||
|
.. _ufs_def:
|
||||||
|
|
||||||
|
Union File System
|
||||||
|
.................
|
||||||
|
|
||||||
|
We call the union of the read-write layer and all the read-only layers
|
||||||
|
a **union file system**.
|
||||||
@@ -17,6 +17,8 @@ This documentation has the following resources:
|
|||||||
commandline/index
|
commandline/index
|
||||||
contributing/index
|
contributing/index
|
||||||
api/index
|
api/index
|
||||||
|
terms/index
|
||||||
faq
|
faq
|
||||||
|
|
||||||
.. image:: concepts/images/lego_docker.jpg
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,19 +33,39 @@ Running an interactive shell
|
|||||||
# allocate a tty, attach stdin and stdout
|
# allocate a tty, attach stdin and stdout
|
||||||
docker run -i -t base /bin/bash
|
docker run -i -t base /bin/bash
|
||||||
|
|
||||||
Bind Docker to another host/port
|
Bind Docker to another host/port or a unix socket
|
||||||
--------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
If you want Docker to listen to another port and bind to another ip
|
With -H it is possible to make the Docker daemon to listen on a specific ip and port. By default, it will listen on 127.0.0.1:4243 to allow only local connections but you can set it to 0.0.0.0:4243 or a specific host ip to give access to everybody.
|
||||||
use -host and -port on both deamon and client
|
|
||||||
|
Similarly, the Docker client can use -H to connect to a custom port.
|
||||||
|
|
||||||
|
-H accepts host and port assignment in the following format: tcp://[host][:port] or unix://path
|
||||||
|
For example:
|
||||||
|
|
||||||
|
* tcp://host -> tcp connection on host:4243
|
||||||
|
* tcp://host:port -> tcp connection on host:port
|
||||||
|
* tcp://:port -> tcp connection on 127.0.0.1:port
|
||||||
|
* unix://path/to/socket -> unix socket located at path/to/socket
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# Run docker in daemon mode
|
# Run docker in daemon mode
|
||||||
sudo <path to>/docker -H 0.0.0.0:5555 &
|
sudo <path to>/docker -H 0.0.0.0:5555 -d &
|
||||||
# Download a base image
|
# Download a base image
|
||||||
docker -H :5555 pull base
|
docker -H :5555 pull base
|
||||||
|
|
||||||
|
You can use multiple -H, for example, if you want to listen
|
||||||
|
on both tcp and a unix socket
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# Run docker in daemon mode
|
||||||
|
sudo <path to>/docker -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock -d &
|
||||||
|
# Download a base image
|
||||||
|
docker pull base
|
||||||
|
# OR
|
||||||
|
docker -H unix:///var/run/docker.sock pull base
|
||||||
|
|
||||||
Starting a long-running worker process
|
Starting a long-running worker process
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
@@ -82,7 +102,8 @@ Expose a service on a TCP port
|
|||||||
|
|
||||||
# Connect to the public port via the host's public address
|
# Connect to the public port via the host's public address
|
||||||
# Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
|
# Please note that because of how routing works connecting to localhost or 127.0.0.1 $PORT will not work.
|
||||||
IP=$(ifconfig eth0 | perl -n -e 'if (m/inet addr:([\d\.]+)/g) { print $1 }')
|
# Replace *eth0* according to your local interface name.
|
||||||
|
IP=$(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { print $1 }')
|
||||||
echo hello world | nc $IP $PORT
|
echo hello world | nc $IP $PORT
|
||||||
|
|
||||||
# Verify that the network connection worked
|
# Verify that the network connection worked
|
||||||
|
|||||||
@@ -1,26 +1,36 @@
|
|||||||
:title: Docker Builder
|
:title: Dockerfiles for Images
|
||||||
:description: Docker Builder specifes a simple DSL which allows you to automate the steps you would normally manually take to create an image.
|
:description: Dockerfiles use a simple DSL which allows you to automate the steps you would normally manually take to create an image.
|
||||||
:keywords: builder, docker, Docker Builder, automation, image creation
|
:keywords: builder, docker, Dockerfile, automation, image creation
|
||||||
|
|
||||||
==============
|
==================
|
||||||
Docker Builder
|
Dockerfile Builder
|
||||||
==============
|
==================
|
||||||
|
|
||||||
|
**Docker can act as a builder** and read instructions from a text
|
||||||
|
Dockerfile to automate the steps you would otherwise make manually to
|
||||||
|
create an image. Executing ``docker build`` will run your steps and
|
||||||
|
commit them along the way, giving you a final image.
|
||||||
|
|
||||||
.. contents:: Table of Contents
|
.. contents:: Table of Contents
|
||||||
|
|
||||||
Docker Builder specifes a simple DSL which allows you to automate the steps you
|
|
||||||
would normally manually take to create an image. Docker Build will run your
|
|
||||||
steps and commit them along the way, giving you a final image.
|
|
||||||
|
|
||||||
1. Usage
|
1. Usage
|
||||||
========
|
========
|
||||||
|
|
||||||
To use Docker Builder, assemble the steps into a text file (commonly referred to
|
To build an image from a source repository, create a description file
|
||||||
as a Dockerfile) and supply this to `docker build` on STDIN, like so:
|
called ``Dockerfile`` at the root of your repository. This file will
|
||||||
|
describe the steps to assemble the image.
|
||||||
|
|
||||||
``docker build - < Dockerfile``
|
Then call ``docker build`` with the path of your source repository as
|
||||||
|
argument:
|
||||||
|
|
||||||
Docker will run your steps one-by-one, committing the result if necessary,
|
``docker build .``
|
||||||
|
|
||||||
|
You can specify a repository and tag at which to save the new image if the
|
||||||
|
build succeeds:
|
||||||
|
|
||||||
|
``docker build -t shykes/myapp .``
|
||||||
|
|
||||||
|
Docker will run your steps one-by-one, committing the result if necessary,
|
||||||
before finally outputting the ID of your new image.
|
before finally outputting the ID of your new image.
|
||||||
|
|
||||||
2. Format
|
2. Format
|
||||||
@@ -28,113 +38,172 @@ before finally outputting the ID of your new image.
|
|||||||
|
|
||||||
The Dockerfile format is quite simple:
|
The Dockerfile format is quite simple:
|
||||||
|
|
||||||
``instruction arguments``
|
::
|
||||||
|
|
||||||
The Instruction is not case-sensitive, however convention is for them to be
|
# Comment
|
||||||
|
INSTRUCTION arguments
|
||||||
|
|
||||||
|
The Instruction is not case-sensitive, however convention is for them to be
|
||||||
UPPERCASE in order to distinguish them from arguments more easily.
|
UPPERCASE in order to distinguish them from arguments more easily.
|
||||||
|
|
||||||
Dockerfiles are evaluated in order, therefore the first instruction must be
|
Docker evaluates the instructions in a Dockerfile in order. **The first
|
||||||
`FROM` in order to specify the base image from which you are building.
|
instruction must be `FROM`** in order to specify the base image from
|
||||||
|
which you are building.
|
||||||
|
|
||||||
Docker will ignore lines in Dockerfiles prefixed with "`#`", so you may add
|
Docker will ignore **comment lines** *beginning* with ``#``. A comment
|
||||||
comment lines. A comment marker in the rest of the line will be treated as an
|
marker anywhere in the rest of the line will be treated as an argument.
|
||||||
argument.
|
|
||||||
|
|
||||||
2. Instructions
|
3. Instructions
|
||||||
===============
|
===============
|
||||||
|
|
||||||
Docker builder comes with a set of instructions, described below.
|
Here is the set of instructions you can use in a ``Dockerfile`` for
|
||||||
|
building images.
|
||||||
|
|
||||||
2.1 FROM
|
3.1 FROM
|
||||||
--------
|
--------
|
||||||
|
|
||||||
``FROM <image>``
|
``FROM <image>``
|
||||||
|
|
||||||
The `FROM` instruction sets the base image for subsequent instructions. As such,
|
The ``FROM`` instruction sets the :ref:`base_image_def` for subsequent
|
||||||
a valid Dockerfile must have it as its first instruction.
|
instructions. As such, a valid Dockerfile must have ``FROM`` as its
|
||||||
|
first instruction.
|
||||||
|
|
||||||
`FROM` can be included multiple times within a single Dockerfile in order to
|
``FROM`` must be the first non-comment instruction in the
|
||||||
create multiple images. Simply make a note of the last image id output by the
|
``Dockerfile``.
|
||||||
commit before each new `FROM` command.
|
|
||||||
|
|
||||||
2.2 MAINTAINER
|
``FROM`` can appear multiple times within a single Dockerfile in order
|
||||||
|
to create multiple images. Simply make a note of the last image id
|
||||||
|
output by the commit before each new ``FROM`` command.
|
||||||
|
|
||||||
|
3.2 MAINTAINER
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
``MAINTAINER <name>``
|
``MAINTAINER <name>``
|
||||||
|
|
||||||
The `MAINTAINER` instruction allows you to set the Author field of the generated
|
The ``MAINTAINER`` instruction allows you to set the *Author* field of
|
||||||
images.
|
the generated images.
|
||||||
|
|
||||||
2.3 RUN
|
3.3 RUN
|
||||||
-------
|
-------
|
||||||
|
|
||||||
``RUN <command>``
|
``RUN <command>``
|
||||||
|
|
||||||
The `RUN` instruction will execute any commands on the current image and commit
|
The ``RUN`` instruction will execute any commands on the current image
|
||||||
the results. The resulting committed image will be used for the next step in the
|
and commit the results. The resulting committed image will be used for
|
||||||
Dockerfile.
|
the next step in the Dockerfile.
|
||||||
|
|
||||||
Layering `RUN` instructions and generating commits conforms to the
|
Layering ``RUN`` instructions and generating commits conforms to the
|
||||||
core concepts of Docker where commits are cheap and containers can be created
|
core concepts of Docker where commits are cheap and containers can be
|
||||||
from any point in an image's history, much like source control.
|
created from any point in an image's history, much like source
|
||||||
|
control.
|
||||||
|
|
||||||
2.4 CMD
|
3.4 CMD
|
||||||
-------
|
-------
|
||||||
|
|
||||||
``CMD <command>``
|
``CMD <command>``
|
||||||
|
|
||||||
The `CMD` instruction sets the command to be executed when running the image.
|
The ``CMD`` instruction sets the command to be executed when running
|
||||||
This is functionally equivalent to running
|
the image. This is functionally equivalent to running ``docker commit
|
||||||
`docker commit -run '{"Cmd": <command>}'` outside the builder.
|
-run '{"Cmd": <command>}'`` outside the builder.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Don't confuse `RUN` with `CMD`. `RUN` actually runs a command and commits
|
Don't confuse `RUN` with `CMD`. `RUN` actually runs a
|
||||||
the result; `CMD` does not execute anything at build time, but specifies the
|
command and commits the result; `CMD` does not execute anything at
|
||||||
intended command for the image.
|
build time, but specifies the intended command for the image.
|
||||||
|
|
||||||
2.5 EXPOSE
|
3.5 EXPOSE
|
||||||
----------
|
----------
|
||||||
|
|
||||||
``EXPOSE <port> [<port>...]``
|
``EXPOSE <port> [<port>...]``
|
||||||
|
|
||||||
The `EXPOSE` instruction sets ports to be publicly exposed when running the
|
The ``EXPOSE`` instruction sets ports to be publicly exposed when
|
||||||
image. This is functionally equivalent to running
|
running the image. This is functionally equivalent to running ``docker
|
||||||
`docker commit -run '{"PortSpecs": ["<port>", "<port2>"]}'` outside the builder.
|
commit -run '{"PortSpecs": ["<port>", "<port2>"]}'`` outside the
|
||||||
|
builder.
|
||||||
|
|
||||||
2.6 ENV
|
3.6 ENV
|
||||||
-------
|
-------
|
||||||
|
|
||||||
``ENV <key> <value>``
|
``ENV <key> <value>``
|
||||||
|
|
||||||
The `ENV` instruction sets the environment variable `<key>` to the value
|
The ``ENV`` instruction sets the environment variable ``<key>`` to the
|
||||||
`<value>`. This value will be passed to all future ``RUN`` instructions. This is
|
value ``<value>``. This value will be passed to all future ``RUN``
|
||||||
functionally equivalent to prefixing the command with `<key>=<value>`
|
instructions. This is functionally equivalent to prefixing the command
|
||||||
|
with ``<key>=<value>``
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
The environment variables will persist when a container is run from the resulting image.
|
The environment variables will persist when a container is run
|
||||||
|
from the resulting image.
|
||||||
|
|
||||||
2.7 INSERT
|
3.7 ADD
|
||||||
----------
|
|
||||||
|
|
||||||
``INSERT <file url> <path>``
|
|
||||||
|
|
||||||
The `INSERT` instruction will download the file from the given url to the given
|
|
||||||
path within the image. It is similar to `RUN curl -o <path> <url>`, assuming
|
|
||||||
curl was installed within the image.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
The path must include the file name.
|
|
||||||
|
|
||||||
2.8 ADD
|
|
||||||
-------
|
-------
|
||||||
|
|
||||||
``ADD <src> <dest>``
|
``ADD <src> <dest>``
|
||||||
|
|
||||||
The `ADD` instruction will insert the files from the `<src>` path of the context into `<dest>` path
|
The ``ADD`` instruction will copy new files from <src> and add them to
|
||||||
of the container.
|
the container's filesystem at path ``<dest>``.
|
||||||
The context must be set in order to use this instruction. (see examples)
|
|
||||||
|
|
||||||
3. Dockerfile Examples
|
``<src>`` must be the path to a file or directory relative to the
|
||||||
|
source directory being built (also called the *context* of the build) or
|
||||||
|
a remote file URL.
|
||||||
|
|
||||||
|
``<dest>`` is the path at which the source will be copied in the
|
||||||
|
destination container.
|
||||||
|
|
||||||
|
The copy obeys the following rules:
|
||||||
|
|
||||||
|
* If ``<src>`` is a URL and ``<dest>`` does not end with a trailing slash,
|
||||||
|
then a file is downloaded from the URL and copied to ``<dest>``.
|
||||||
|
* If ``<src>`` is a URL and ``<dest>`` does end with a trailing slash,
|
||||||
|
then the filename is inferred from the URL and the file is downloaded to
|
||||||
|
``<dest>/<filename>``. For instance, ``ADD http://example.com/foobar /``
|
||||||
|
would create the file ``/foobar``. The URL must have a nontrivial path
|
||||||
|
so that an appropriate filename can be discovered in this case
|
||||||
|
(``http://example.com`` will not work).
|
||||||
|
* If ``<src>`` is a directory, the entire directory is copied,
|
||||||
|
including filesystem metadata.
|
||||||
|
* If ``<src>``` is a tar archive in a recognized compression format
|
||||||
|
(identity, gzip, bzip2 or xz), it is unpacked as a directory.
|
||||||
|
|
||||||
|
When a directory is copied or unpacked, it has the same behavior as
|
||||||
|
``tar -x``: the result is the union of
|
||||||
|
|
||||||
|
1. whatever existed at the destination path and
|
||||||
|
2. the contents of the source tree,
|
||||||
|
|
||||||
|
with conflicts resolved in favor of 2) on a file-by-file basis.
|
||||||
|
|
||||||
|
* If ``<src>`` is any other kind of file, it is copied individually
|
||||||
|
along with its metadata. In this case, if ``<dst>`` ends with a
|
||||||
|
trailing slash ``/``, it will be considered a directory and the
|
||||||
|
contents of ``<src>`` will be written at ``<dst>/base(<src>)``.
|
||||||
|
* If ``<dst>`` does not end with a trailing slash, it will be
|
||||||
|
considered a regular file and the contents of ``<src>`` will be
|
||||||
|
written at ``<dst>``.
|
||||||
|
* If ``<dest>`` doesn't exist, it is created along with all missing
|
||||||
|
directories in its path. All new files and directories are created
|
||||||
|
with mode 0700, uid and gid 0.
|
||||||
|
|
||||||
|
3.8 ENTRYPOINT
|
||||||
|
--------------
|
||||||
|
|
||||||
|
``ENTRYPOINT ["/bin/echo"]``
|
||||||
|
|
||||||
|
The ``ENTRYPOINT`` instruction adds an entry command that will not be
|
||||||
|
overwritten when arguments are passed to docker run, unlike the
|
||||||
|
behavior of ``CMD``. This allows arguments to be passed to the
|
||||||
|
entrypoint. i.e. ``docker run <image> -d`` will pass the "-d" argument
|
||||||
|
to the entrypoint.
|
||||||
|
|
||||||
|
3.9 VOLUME
|
||||||
|
----------
|
||||||
|
|
||||||
|
``VOLUME ["/data"]``
|
||||||
|
|
||||||
|
The ``VOLUME`` instruction will add one or more new volumes to any
|
||||||
|
container created from the image.
|
||||||
|
|
||||||
|
4. Dockerfile Examples
|
||||||
======================
|
======================
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
@@ -142,28 +211,27 @@ The context must be set in order to use this instruction. (see examples)
|
|||||||
# Nginx
|
# Nginx
|
||||||
#
|
#
|
||||||
# VERSION 0.0.1
|
# VERSION 0.0.1
|
||||||
|
|
||||||
FROM ubuntu
|
FROM ubuntu
|
||||||
MAINTAINER Guillaume J. Charmes "guillaume@dotcloud.com"
|
MAINTAINER Guillaume J. Charmes "guillaume@dotcloud.com"
|
||||||
|
|
||||||
# make sure the package repository is up to date
|
# make sure the package repository is up to date
|
||||||
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
|
||||||
RUN apt-get install -y inotify-tools nginx apache2 openssh-server
|
RUN apt-get install -y inotify-tools nginx apache2 openssh-server
|
||||||
INSERT https://raw.github.com/creack/docker-vps/master/nginx-wrapper.sh /usr/sbin/nginx-wrapper
|
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# Firefox over VNC
|
# Firefox over VNC
|
||||||
#
|
#
|
||||||
# VERSION 0.3
|
# VERSION 0.3
|
||||||
|
|
||||||
FROM ubuntu
|
FROM ubuntu
|
||||||
# make sure the package repository is up to date
|
# make sure the package repository is up to date
|
||||||
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
|
|
||||||
# Install vnc, xvfb in order to create a 'fake' display and firefox
|
# Install vnc, xvfb in order to create a 'fake' display and firefox
|
||||||
RUN apt-get install -y x11vnc xvfb firefox
|
RUN apt-get install -y x11vnc xvfb firefox
|
||||||
RUN mkdir /.vnc
|
RUN mkdir /.vnc
|
||||||
@@ -171,7 +239,7 @@ The context must be set in order to use this instruction. (see examples)
|
|||||||
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
|
RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
|
||||||
# Autostart firefox (might not be the best way, but it does the trick)
|
# Autostart firefox (might not be the best way, but it does the trick)
|
||||||
RUN bash -c 'echo "firefox" >> /.bashrc'
|
RUN bash -c 'echo "firefox" >> /.bashrc'
|
||||||
|
|
||||||
EXPOSE 5900
|
EXPOSE 5900
|
||||||
CMD ["x11vnc", "-forever", "-usepw", "-create"]
|
CMD ["x11vnc", "-forever", "-usepw", "-create"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,75 @@
|
|||||||
:title: Working With Repositories
|
:title: Working With Repositories
|
||||||
:description: Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind Docker, and user repositories.
|
:description: Repositories allow users to share images.
|
||||||
:keywords: repo, repositiores, usage, pull image, push image, image, documentation
|
:keywords: repo, repositiores, usage, pull image, push image, image, documentation
|
||||||
|
|
||||||
.. _working_with_the_repository:
|
.. _working_with_the_repository:
|
||||||
|
|
||||||
Working with the Repository
|
Working with Repositories
|
||||||
===========================
|
=========================
|
||||||
|
|
||||||
|
A *repository* is a hosted collection of tagged :ref:`images
|
||||||
|
<image_def>` that together create the file system for a container. The
|
||||||
|
repository's name is a tag that indicates the provenance of the
|
||||||
|
repository, i.e. who created it and where the original copy is
|
||||||
|
located.
|
||||||
|
|
||||||
Top-level repositories and user repositories
|
You can find one or more repositories hosted on a *registry*. There
|
||||||
--------------------------------------------
|
can be an implicit or explicit host name as part of the repository
|
||||||
|
tag. The implicit registry is located at ``index.docker.io``, the home
|
||||||
|
of "top-level" repositories and the Central Index. This registry may
|
||||||
|
also include public "user" repositories.
|
||||||
|
|
||||||
Generally, there are two types of repositories: Top-level repositories which are controlled by the people behind
|
So Docker is not only a tool for creating and managing your own
|
||||||
Docker, and user repositories.
|
:ref:`containers <container_def>` -- **Docker is also a tool for
|
||||||
|
sharing**. The Docker project provides a Central Registry to host
|
||||||
|
public repositories, namespaced by user, and a Central Index which
|
||||||
|
provides user authentication and search over all the public
|
||||||
|
repositories. You can host your own Registry too! Docker acts as a
|
||||||
|
client for these services via ``docker search, pull, login`` and
|
||||||
|
``push``.
|
||||||
|
|
||||||
* Top-level repositories can easily be recognized by not having a ``/`` (slash) in their name. These repositories can
|
Top-level, User, and Your Own Repositories
|
||||||
generally be trusted.
|
------------------------------------------
|
||||||
* User repositories always come in the form of ``<username>/<repo_name>``. This is what your published images will look like.
|
|
||||||
* User images are not checked, it is therefore up to you whether or not you trust the creator of this image.
|
|
||||||
|
|
||||||
|
There are two types of public repositories: *top-level* repositories
|
||||||
|
which are controlled by the Docker team, and *user* repositories
|
||||||
|
created by individual contributors.
|
||||||
|
|
||||||
Find public images available on the index
|
* Top-level repositories can easily be recognized by **not** having a
|
||||||
-----------------------------------------
|
``/`` (slash) in their name. These repositories can generally be
|
||||||
|
trusted.
|
||||||
|
* User repositories always come in the form of
|
||||||
|
``<username>/<repo_name>``. This is what your published images will
|
||||||
|
look like if you push to the public Central Registry.
|
||||||
|
* Only the authenticated user can push to their *username* namespace
|
||||||
|
on the Central Registry.
|
||||||
|
* User images are not checked, it is therefore up to you whether or
|
||||||
|
not you trust the creator of this image.
|
||||||
|
|
||||||
|
Right now (version 0.5), private repositories are only possible by
|
||||||
|
hosting `your own registry
|
||||||
|
<https://github.com/dotcloud/docker-registry>`_. To push or pull to a
|
||||||
|
repository on your own registry, you must prefix the tag with the
|
||||||
|
address of the registry's host, like this:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# Tag to create a repository with the full registry location.
|
||||||
|
# The location (e.g. localhost.localdomain:5000) becomes
|
||||||
|
# a permanent part of the repository name
|
||||||
|
docker tag 0u812deadbeef localhost.localdomain:5000/repo_name
|
||||||
|
|
||||||
|
# Push the new repository to its home location on localhost
|
||||||
|
docker push localhost.localdomain:5000/repo_name
|
||||||
|
|
||||||
|
Once a repository has your registry's host name as part of the tag,
|
||||||
|
you can push and pull it like any other repository, but it will
|
||||||
|
**not** be searchable (or indexed at all) in the Central Index, and
|
||||||
|
there will be no user name checking performed. Your registry will
|
||||||
|
function completely independently from the Central Index.
|
||||||
|
|
||||||
|
Find public images available on the Central Index
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
Seach by name, namespace or description
|
Seach by name, namespace or description
|
||||||
|
|
||||||
@@ -37,43 +85,48 @@ Download them simply by their name
|
|||||||
docker pull <value>
|
docker pull <value>
|
||||||
|
|
||||||
|
|
||||||
Very similarly you can search for and browse the index online on https://index.docker.io
|
Very similarly you can search for and browse the index online on
|
||||||
|
https://index.docker.io
|
||||||
|
|
||||||
|
|
||||||
Connecting to the repository
|
Connecting to the Central Registry
|
||||||
----------------------------
|
----------------------------------
|
||||||
|
|
||||||
You can create a user on the central docker repository online, or by running
|
You can create a user on the central Docker Index online, or by running
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
docker login
|
docker login
|
||||||
|
|
||||||
|
This will prompt you for a username, which will become a public
|
||||||
|
namespace for your public repositories.
|
||||||
|
|
||||||
If your username does not exist it will prompt you to also enter a password and your e-mail address. It will then
|
If your username does not exist it will prompt you to also enter a
|
||||||
automatically log you in.
|
password and your e-mail address. It will then automatically log you
|
||||||
|
in.
|
||||||
|
|
||||||
|
|
||||||
Committing a container to a named image
|
Committing a container to a named image
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
In order to commit to the repository it is required to have committed your container to an image with your namespace.
|
In order to commit to the repository it is required to have committed
|
||||||
|
your container to an image within your username namespace.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# for example docker commit $CONTAINER_ID dhrp/kickassapp
|
# for example docker commit $CONTAINER_ID dhrp/kickassapp
|
||||||
docker commit <container_id> <your username>/<some_name>
|
docker commit <container_id> <username>/<repo_name>
|
||||||
|
|
||||||
|
|
||||||
Pushing a container to the repository
|
Pushing a container to its repository
|
||||||
-----------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
In order to push an image to the repository you need to have committed your container to a named image (see above)
|
In order to push an image to its repository you need to have committed
|
||||||
|
your container to a named image (see above)
|
||||||
|
|
||||||
Now you can commit this image to the repository
|
Now you can commit this image to the repository
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
# for example docker push dhrp/kickassapp
|
# for example docker push dhrp/kickassapp
|
||||||
docker push <image-name>
|
docker push <username>/<repo_name>
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
Thatcher Penskens <thatcher@dotcloud.com>
|
Thatcher Peskens <thatcher@dotcloud.com>
|
||||||
|
|||||||
@@ -40,6 +40,11 @@
|
|||||||
|
|
||||||
{%- set script_files = script_files + ['_static/js/docs.js'] %}
|
{%- set script_files = script_files + ['_static/js/docs.js'] %}
|
||||||
|
|
||||||
|
{%- if pagename == 'index' %}
|
||||||
|
<link rel="canonical" href="http://docs.docker.io/en/latest/">
|
||||||
|
{% else %}
|
||||||
|
<link rel="canonical" href="http://docs.docker.io/en/latest/{{ pagename }}/">
|
||||||
|
{% endif %}
|
||||||
{%- for cssfile in css_files %}
|
{%- for cssfile in css_files %}
|
||||||
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
|
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
@@ -48,9 +53,8 @@
|
|||||||
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
|
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- if favicon %}
|
<link rel="shortcut icon" href="{{ pathto('_static/favicon.png', 1) }}"/>
|
||||||
<link rel="shortcut icon" href="{{ pathto('_static/' + favicon, 1) }}"/>
|
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
{%- block extrahead %}{% endblock %}
|
{%- block extrahead %}{% endblock %}
|
||||||
|
|
||||||
@@ -64,19 +68,18 @@
|
|||||||
|
|
||||||
<div style="float: right" class="pull-right">
|
<div style="float: right" class="pull-right">
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li id="nav-introduction"><a href="http://www.docker.io/">Introduction</a></li>
|
<li id="nav-introduction"><a href="http://www.docker.io/" title="Docker Homepage">Home</a></li>
|
||||||
|
<li id="nav-about"><a href="http://www.docker.io/about/" title="About">About</a></li>
|
||||||
|
<li id="nav-community"><a href="http://www.docker.io/community/" title="Community">Community</a></li>
|
||||||
<li id="nav-gettingstarted"><a href="http://www.docker.io/gettingstarted/">Getting started</a></li>
|
<li id="nav-gettingstarted"><a href="http://www.docker.io/gettingstarted/">Getting started</a></li>
|
||||||
<li id="nav-documentation" class="active"><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
|
<li id="nav-documentation" class="active"><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
|
||||||
<li id="nav-blog"><a href="http://blog.docker.io/">Blog</a></li>
|
<li id="nav-blog"><a href="http://blog.docker.io/" title="Docker Blog">Blog</a></li>
|
||||||
|
<li id="nav-index"><a href="http://index.docker.io/" title="Docker Image Index, find images here">INDEX <img class="inline-icon" src="{{ pathto('_static/img/external-link-icon.png', 1) }}" title="external link"> </a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<!--<div class="social links" style="float: right; margin-top: 14px; margin-left: 12px">-->
|
|
||||||
<!--<a class="twitter" href="http://twitter.com/getdocker">Twitter</a>-->
|
|
||||||
<!--<a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>-->
|
|
||||||
<!--</div>-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="margin-left: -12px; float: left;">
|
<div style="margin-left: -12px; float: left;">
|
||||||
<a href="http://www.docker.io"><img style="margin-top: 12px; height: 38px" src="{{ pathto('_static/img/docker-letters-logo.gif', 1) }}"></a>
|
<a href="http://www.docker.io" title="Docker Homepage"><img style="margin-top: 0px; height: 60px; margin-left: 10px;" src="{{ pathto('_static/img/docker-top-logo.png', 1) }}"></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@
|
|||||||
<div class="pull-right" id="fork-us" style="margin-top: 16px; margin-right: 16px;">
|
<div class="pull-right" id="fork-us" style="margin-top: 16px; margin-right: 16px;">
|
||||||
<a href="http://github.com/dotcloud/docker/"><img src="{{ pathto('_static/img/fork-us.png', 1) }}"> Fork us on Github</a>
|
<a href="http://github.com/dotcloud/docker/"><img src="{{ pathto('_static/img/fork-us.png', 1) }}"> Fork us on Github</a>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="pageheader">DOCUMENTATION</h1>
|
<h1 class="pageheader"><a href="http://docs.docker.io/en/latest/" title="Documentation" style="color: white;">DOCUMENTATION</a></h1>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,11 +107,8 @@
|
|||||||
<!-- Docs nav
|
<!-- Docs nav
|
||||||
================================================== -->
|
================================================== -->
|
||||||
<div class="row" style="position: relative">
|
<div class="row" style="position: relative">
|
||||||
<div class="span3" style="height:100%;" >
|
|
||||||
|
|
||||||
</div>
|
<div class="span3 sidebar bs-docs-sidebar">
|
||||||
|
|
||||||
<div class="span3 sidebar bs-docs-sidebar" style="position: absolute">
|
|
||||||
{{ toctree(collapse=False, maxdepth=3) }}
|
{{ toctree(collapse=False, maxdepth=3) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Page Moved</title>
|
||||||
|
<meta http-equiv="refresh" content="0; url=http://docs.docker.io/en/latest/use/builder/">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
This page has moved. Perhaps you should visit the <a href="http://docs.docker.io/en/latest/use/builder/" title="builder page">Builder page</a>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Page Moved</title>
|
||||||
|
<meta http-equiv="refresh" content="0; url=http://docs.docker.io/en/latest/">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
This page has moved. Perhaps you should visit the <a href="http://docs.docker.io/" title="documentation homepage">Documentation Homepage</a>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -34,12 +34,12 @@ h4 {
|
|||||||
.navbar .nav li a {
|
.navbar .nav li a {
|
||||||
padding: 22px 15px 22px;
|
padding: 22px 15px 22px;
|
||||||
}
|
}
|
||||||
.navbar .brand {
|
|
||||||
padding: 13px 10px 13px 28px ;
|
|
||||||
}
|
|
||||||
.navbar-dotcloud .container {
|
.navbar-dotcloud .container {
|
||||||
border-bottom: 2px #000000 solid;
|
border-bottom: 2px #000000 solid;
|
||||||
}
|
}
|
||||||
|
.inline-icon {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Responsive YouTube, Vimeo, Embed, and HTML5 Videos with CSS
|
* Responsive YouTube, Vimeo, Embed, and HTML5 Videos with CSS
|
||||||
* http://www.jonsuh.com
|
* http://www.jonsuh.com
|
||||||
@@ -82,7 +82,7 @@ h4 {
|
|||||||
.btn-custom {
|
.btn-custom {
|
||||||
background-color: #292929 !important;
|
background-color: #292929 !important;
|
||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
filter: progid:dximagetransform.microsoft.gradient(startColorstr="#515151", endColorstr="#282828");
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#515151", endColorstr="#282828");
|
||||||
background-image: -khtml-gradient(linear, left top, left bottom, from(#515151), to(#282828));
|
background-image: -khtml-gradient(linear, left top, left bottom, from(#515151), to(#282828));
|
||||||
background-image: -moz-linear-gradient(top, #515151, #282828);
|
background-image: -moz-linear-gradient(top, #515151, #282828);
|
||||||
background-image: -ms-linear-gradient(top, #515151, #282828);
|
background-image: -ms-linear-gradient(top, #515151, #282828);
|
||||||
@@ -168,10 +168,13 @@ section.header {
|
|||||||
.sidebar {
|
.sidebar {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
float: left;
|
float: left;
|
||||||
min-height: 475px;
|
/* min-height: 475px;*/
|
||||||
|
|
||||||
background: #ececec;
|
background: #ececec;
|
||||||
border-left: 1px solid #bbbbbb;
|
/* border-left: 1px solid #bbbbbb;*/
|
||||||
border-right: 1px solid #cccccc;
|
|
||||||
|
/* border-right: 1px solid #cccccc;*/
|
||||||
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.sidebar ul {
|
.sidebar ul {
|
||||||
@@ -298,7 +301,7 @@ section.header {
|
|||||||
height: 28px;
|
height: 28px;
|
||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
background-color: #43484c;
|
background-color: #43484c;
|
||||||
filter: progid:dximagetransform.microsoft.gradient(gradientType=0, startColorstr='#FFFF6E56', endColorstr='#FFED4F35');
|
filter: progid:DXImageTransform.Microsoft.gradient(gradientType=0, startColorstr='#FFFF6E56', endColorstr='#FFED4F35');
|
||||||
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #747474), color-stop(100%, #43484c));
|
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #747474), color-stop(100%, #43484c));
|
||||||
background-image: -webkit-linear-gradient(top, #747474 0%, #43484c 100%);
|
background-image: -webkit-linear-gradient(top, #747474 0%, #43484c 100%);
|
||||||
background-image: -moz-linear-gradient(top, #747474 0%, #43484c 100%);
|
background-image: -moz-linear-gradient(top, #747474 0%, #43484c 100%);
|
||||||
@@ -357,7 +360,6 @@ section.header {
|
|||||||
#global {
|
#global {
|
||||||
/* TODO: Fix this to be relative to the navigation size */
|
/* TODO: Fix this to be relative to the navigation size */
|
||||||
|
|
||||||
padding-top: 600px;
|
|
||||||
}
|
}
|
||||||
#fork-us {
|
#fork-us {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -53,13 +53,6 @@ h1, h2, h3, h4 {
|
|||||||
padding: 22px 15px 22px;
|
padding: 22px 15px 22px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand {
|
|
||||||
padding: 13px 10px 13px 28px ;
|
|
||||||
// padding-left: 30px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +60,9 @@ h1, h2, h3, h4 {
|
|||||||
border-bottom: 2px @black solid;
|
border-bottom: 2px @black solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.inline-icon {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Responsive YouTube, Vimeo, Embed, and HTML5 Videos with CSS
|
* Responsive YouTube, Vimeo, Embed, and HTML5 Videos with CSS
|
||||||
@@ -226,20 +222,21 @@ section.header {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
// font-family: "Maven Pro";
|
||||||
|
font-weight: normal;
|
||||||
|
// margin-top: 38px;
|
||||||
|
float: left;
|
||||||
|
// width: 220px;
|
||||||
|
/* min-height: 475px;*/
|
||||||
|
// margin-bottom: 28px;
|
||||||
|
// padding-bottom: 120px;
|
||||||
|
background: #ececec;
|
||||||
|
/* border-left: 1px solid #bbbbbb;*/
|
||||||
|
/* border-right: 1px solid #cccccc;*/
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
// font-family: "Maven Pro";
|
|
||||||
font-weight: normal;
|
|
||||||
// margin-top: 38px;
|
|
||||||
float: left;
|
|
||||||
// width: 220px;
|
|
||||||
min-height: 475px;
|
|
||||||
// margin-bottom: 28px;
|
|
||||||
// padding-bottom: 120px;
|
|
||||||
background: #ececec;
|
|
||||||
border-left: 1px solid #bbbbbb;
|
|
||||||
border-right: 1px solid #cccccc;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
@@ -471,7 +468,7 @@ section.header {
|
|||||||
}
|
}
|
||||||
#global {
|
#global {
|
||||||
/* TODO: Fix this to be relative to the navigation size */
|
/* TODO: Fix this to be relative to the navigation size */
|
||||||
padding-top: 600px;
|
// padding-top: 600px;
|
||||||
}
|
}
|
||||||
#fork-us {
|
#fork-us {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 404 B |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -1 +0,0 @@
|
|||||||
Thatcher Penskens <thatcher@dotcloud.com>
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
www:
|
|
||||||
type: static
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
|
||||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
|
||||||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
|
||||||
<!--[if gt IE 8]><!-->
|
|
||||||
<html class="no-js" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
||||||
<title>Docker - the Linux container runtime</title>
|
|
||||||
|
|
||||||
<meta name="description" content="Docker encapsulates heterogeneous payloads in standard containers">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
|
|
||||||
<!-- twitter bootstrap -->
|
|
||||||
<link rel="stylesheet" href="../static/css/bootstrap.min.css">
|
|
||||||
<link rel="stylesheet" href="../static/css/bootstrap-responsive.min.css">
|
|
||||||
|
|
||||||
<!-- main style file -->
|
|
||||||
<link rel="stylesheet" href="../static/css/main.css">
|
|
||||||
|
|
||||||
<!-- vendor scripts -->
|
|
||||||
<script src="../static/js/vendor/jquery-1.9.1.min.js" type="text/javascript" ></script>
|
|
||||||
<script src="../static/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js" type="text/javascript" ></script>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-fixed-top">
|
|
||||||
<div class="navbar-dotcloud">
|
|
||||||
<div class="container" style="text-align: center;">
|
|
||||||
|
|
||||||
<div style="float: right" class="pull-right">
|
|
||||||
<ul class="nav">
|
|
||||||
<li id="nav-introduction"><a href="../">Introduction</a></li>
|
|
||||||
<li id="nav-gettingstarted" class="active"><a href="">Getting started</a></li>
|
|
||||||
<li id="nav-documentation" class=""><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
|
|
||||||
<li id="nav-blog"><a href="http://blog.docker.io/">Blog</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="margin-left: -12px; float: left;">
|
|
||||||
<a href="../index.html"><img style="margin-top: 12px; height: 38px" src="../static/img/docker-letters-logo.gif"></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="span12 titlebar">
|
|
||||||
|
|
||||||
<div class="pull-right" id="fork-us" style="margin-top: 16px; margin-right: 16px;">
|
|
||||||
<a href="http://github.com/dotcloud/docker/"><img src="../static/img/fork-us.png"> Fork us on Github</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1 class="pageheader"> GETTING STARTED</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="alert alert-info" style="margin-bottom: 0;">
|
|
||||||
<strong>Docker is still under heavy development.</strong> It should not yet be used in production. Check <a href="http://github.com/dotcloud/docker">the repo</a> for recent progress.
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock">
|
|
||||||
<h2>
|
|
||||||
<a name="installing-on-ubuntu-1204-and-1210" class="anchor" href="#installing-on-ubuntu-1204-and-1210"><span class="mini-icon mini-icon-link"></span>
|
|
||||||
</a>Installing on Ubuntu</h2>
|
|
||||||
|
|
||||||
<p><strong>Requirements</strong></p>
|
|
||||||
<ul>
|
|
||||||
<li>Ubuntu 12.04 (LTS) (64-bit)</li>
|
|
||||||
<li> or Ubuntu 12.10 (quantal) (64-bit)</li>
|
|
||||||
<li>The 3.8 Linux Kernel</li>
|
|
||||||
</ul>
|
|
||||||
<ol>
|
|
||||||
<li>
|
|
||||||
<p><strong>Install dependencies</strong></p>
|
|
||||||
The linux-image-extra package is only needed on standard Ubuntu EC2 AMIs in order to install the aufs kernel module.
|
|
||||||
<pre>sudo apt-get install linux-image-extra-`uname -r`</pre>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<p><strong>Install Docker</strong></p>
|
|
||||||
<p>Add the Ubuntu PPA (Personal Package Archive) sources to your apt sources list, update and install.</p>
|
|
||||||
<p>This may import a new GPG key (key 63561DC6: public key "Launchpad PPA for dotcloud team" imported).</p>
|
|
||||||
<div class="highlight">
|
|
||||||
<pre>sudo apt-get install software-properties-common</pre>
|
|
||||||
<pre>sudo add-apt-repository ppa:dotcloud/lxc-docker</pre>
|
|
||||||
<pre>sudo apt-get update</pre>
|
|
||||||
<pre>sudo apt-get install lxc-docker</pre>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<p><strong>Run!</strong></p>
|
|
||||||
|
|
||||||
<div class="highlight">
|
|
||||||
<pre>docker run -i -t ubuntu /bin/bash</pre>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
Continue with the <a href="http://docs.docker.io/en/latest/examples/hello_world/">Hello world</a> example.<br>
|
|
||||||
Or check <a href="http://docs.docker.io/en/latest/installation/ubuntulinux/">more detailed installation instructions</a>
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="contentblock">
|
|
||||||
<h2>Contributing to Docker</h2>
|
|
||||||
|
|
||||||
<p>Want to hack on Docker? Awesome! We have some <a href="http://docs.docker.io/en/latest/contributing/contributing/">instructions to get you started</a>. They are probably not perfect, please let us know if anything feels wrong or incomplete.</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock">
|
|
||||||
<h2>Quick install on other operating systems</h2>
|
|
||||||
<p><strong>For other operating systems we recommend and provide a streamlined install with virtualbox,
|
|
||||||
vagrant and an Ubuntu virtual machine.</strong></p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://docs.docker.io/en/latest/installation/vagrant/">Mac OS X and other linuxes</a></li>
|
|
||||||
<li><a href="http://docs.docker.io/en/latest/installation/windows/">Windows</a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="contentblock">
|
|
||||||
<h2>Questions? Want to get in touch?</h2>
|
|
||||||
<p>There are several ways to get in touch:</p>
|
|
||||||
<p><strong>Join the discussion on IRC.</strong> We can be found in the <a href="irc://chat.freenode.net#docker">#docker</a> channel on chat.freenode.net</p>
|
|
||||||
<p><strong>Discussions</strong> happen on our google group: <a href="https://groups.google.com/d/forum/docker-club">docker-club at googlegroups.com</a></p>
|
|
||||||
<p>All our <strong>development and decisions</strong> are made out in the open on Github <a href="http://www.github.com/dotcloud/docker">github.com/dotcloud/docker</a></p>
|
|
||||||
<p><strong>Get help on using Docker</strong> by asking on <a href="http://stackoverflow.com/tags/docker/">Stackoverflow</a></p>
|
|
||||||
<p>And of course, <strong>tweet</strong> your tweets to <a href="http://twitter.com/getdocker/">twitter.com/getdocker</a></p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
<section class="contentblock">
|
|
||||||
<div id="wufoo-z7x3p3">
|
|
||||||
Fill out my <a href="http://dotclouddocker.wufoo.com/forms/z7x3p3">online form</a>.
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">var z7x3p3;(function(d, t) {
|
|
||||||
var s = d.createElement(t), options = {
|
|
||||||
'userName':'dotclouddocker',
|
|
||||||
'formHash':'z7x3p3',
|
|
||||||
'autoResize':true,
|
|
||||||
'height':'577',
|
|
||||||
'async':true,
|
|
||||||
'header':'show'};
|
|
||||||
s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js';
|
|
||||||
s.onload = s.onreadystatechange = function() {
|
|
||||||
var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return;
|
|
||||||
try { z7x3p3 = new WufooForm();z7x3p3.initialize(options);z7x3p3.display(); } catch (e) {}};
|
|
||||||
var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr);
|
|
||||||
})(document, 'script');</script>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<footer id="footer" class="footer">
|
|
||||||
<div class="row">
|
|
||||||
<div class="span12 social">
|
|
||||||
<div class="tbox textright forceleftmargin social links pull-right">
|
|
||||||
<a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
|
|
||||||
<a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
|
|
||||||
</div>
|
|
||||||
Docker is a project by <a href="http://www.dotcloud.com">dotCloud</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="emptyspace" style="height: 40px">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- bootstrap javascipts -->
|
|
||||||
<script src="../static/js/vendor/bootstrap.min.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
<!-- Google analytics -->
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
var _gaq = _gaq || [];
|
|
||||||
_gaq.push(['_setAccount', 'UA-6096819-11']);
|
|
||||||
_gaq.push(['_setDomainName', 'docker.io']);
|
|
||||||
_gaq.push(['_setAllowLinker', true]);
|
|
||||||
_gaq.push(['_trackPageview']);
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,359 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
|
||||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
|
||||||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
|
||||||
<!--[if gt IE 8]><!-->
|
|
||||||
<html class="no-js" xmlns="http://www.w3.org/1999/html"> <!--<![endif]-->
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
||||||
<meta name="google-site-verification" content="UxV66EKuPe87dgnH1sbrldrx6VsoWMrx5NjwkgUFxXI" />
|
|
||||||
<title>Docker - the Linux container engine</title>
|
|
||||||
|
|
||||||
<meta name="description" content="Docker encapsulates heterogeneous payloads in standard containers">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
|
|
||||||
<!-- twitter bootstrap -->
|
|
||||||
<link rel="stylesheet" href="static/css/bootstrap.min.css">
|
|
||||||
<link rel="stylesheet" href="static/css/bootstrap-responsive.min.css">
|
|
||||||
|
|
||||||
<!-- main style file -->
|
|
||||||
<link rel="stylesheet" href="static/css/main.css">
|
|
||||||
|
|
||||||
<!-- vendor scripts -->
|
|
||||||
<script src="static/js/vendor/jquery-1.9.1.min.js" type="text/javascript" ></script>
|
|
||||||
<script src="static/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js" type="text/javascript" ></script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.indexlabel {
|
|
||||||
float: left;
|
|
||||||
width: 150px;
|
|
||||||
display: block;
|
|
||||||
padding: 10px 20px 10px;
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: 200;
|
|
||||||
background-color: #a30000;
|
|
||||||
color: white;
|
|
||||||
height: 22px;
|
|
||||||
}
|
|
||||||
.searchbutton {
|
|
||||||
font-size: 20px;
|
|
||||||
height: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.debug {
|
|
||||||
border: 1px red dotted;
|
|
||||||
}
|
|
||||||
.twitterblock {
|
|
||||||
min-height: 75px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.twitterblock img {
|
|
||||||
float: left;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<div class="navbar navbar-fixed-top">
|
|
||||||
<div class="navbar-dotcloud">
|
|
||||||
<div class="container" style="text-align: center;">
|
|
||||||
|
|
||||||
|
|
||||||
<div class="pull-left" id="fork-us" style="margin-top: 16px;">
|
|
||||||
<a href="http://github.com/dotcloud/docker/"><img src="static/img/fork-us.png" alt="fork-icon"> Fork us on Github</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="pull-right" >
|
|
||||||
<ul class="nav">
|
|
||||||
<li id="nav-introduction" class="active"><a href="/">Introduction</a></li>
|
|
||||||
<li id="nav-gettingstarted"><a href="gettingstarted">Getting started</a></li>
|
|
||||||
<li id="nav-documentation" class=""><a href="http://docs.docker.io/en/latest/">Documentation</a></li>
|
|
||||||
<li id="nav-blog"><a href="http://blog.docker.io/">Blog</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container" style="margin-top: 30px;">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="span12">
|
|
||||||
<section class="contentblock header">
|
|
||||||
|
|
||||||
<div class="span5" style="margin-bottom: 15px;">
|
|
||||||
<div style="text-align: center;" >
|
|
||||||
<img src="static/img/docker_letters_500px.png" alt="docker letters">
|
|
||||||
|
|
||||||
<h2>The Linux container engine</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="display: block; text-align: center; margin-top: 20px;">
|
|
||||||
|
|
||||||
<h5>
|
|
||||||
Docker is an open-source engine which automates the deployment of applications as highly portable, self-sufficient containers which are independent of hardware, language, framework, packaging system and hosting provider.
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div style="display: block; text-align: center; margin-top: 30px;">
|
|
||||||
<a class="btn btn-custom btn-large" href="gettingstarted/">Let's get started</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="span6" >
|
|
||||||
<div class="js-video" >
|
|
||||||
<iframe width="600" height="360" src="http://www.youtube.com/embed/wW9CAH9nSLs?feature=player_detailpage&rel=0&modestbranding=1&start=11" frameborder="0" allowfullscreen></iframe>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<br style="clear: both"/>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock">
|
|
||||||
<h4>Heterogeneous payloads</h4>
|
|
||||||
<p>Any combination of binaries, libraries, configuration files, scripts, virtualenvs, jars, gems, tarballs, you name it. No more juggling between domain-specific tools. Docker can deploy and run them all.</p>
|
|
||||||
<h4>Any server</h4>
|
|
||||||
<p>Docker can run on any x64 machine with a modern linux kernel - whether it's a laptop, a bare metal server or a VM. This makes it perfect for multi-cloud deployments.</p>
|
|
||||||
<h4>Isolation</h4>
|
|
||||||
<p>Docker isolates processes from each other and from the underlying host, using lightweight containers.</p>
|
|
||||||
<h4>Repeatability</h4>
|
|
||||||
<p>Because each container is isolated in its own filesystem, they behave the same regardless of where, when, and alongside what they run.</p>
|
|
||||||
</section>
|
|
||||||
<section class="contentblock">
|
|
||||||
<div class="container">
|
|
||||||
<div class="span2" style="margin-left: 0" >
|
|
||||||
<a href="http://dotcloud.theresumator.com/apply/mWjkD4/Software-Engineer.html" title="Job description"><img src="static/img/hiring_graphic.png" alt="we're hiring" width="140" style="margin-top: 25px"></a>
|
|
||||||
</div>
|
|
||||||
<div class="span4" style="margin-left: 0">
|
|
||||||
<h4>Do you think it is cool to hack on docker? Join us!</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Work on open source</li>
|
|
||||||
<li>Program in Go</li>
|
|
||||||
</ul>
|
|
||||||
<a href="http://dotcloud.theresumator.com/apply/mWjkD4/Software-Engineer.html" title="Job description">read more</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock">
|
|
||||||
<h1>New! Docker Index</h1>
|
|
||||||
On the Docker Index you can find and explore pre-made container images. It allows you to share your images and download them.
|
|
||||||
|
|
||||||
<br><br>
|
|
||||||
<a href="https://index.docker.io" target="_blank">
|
|
||||||
<div class="indexlabel">
|
|
||||||
DOCKER index
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<input type="button" class="searchbutton" value="Search images"
|
|
||||||
onClick="window.open('https://index.docker.io')" />
|
|
||||||
|
|
||||||
</section>
|
|
||||||
<section class="contentblock">
|
|
||||||
<div id="wufoo-z7x3p3">
|
|
||||||
Fill out my <a href="http://dotclouddocker.wufoo.com/forms/z7x3p3">online form</a>.
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">var z7x3p3;(function(d, t) {
|
|
||||||
var s = d.createElement(t), options = {
|
|
||||||
'userName':'dotclouddocker',
|
|
||||||
'formHash':'z7x3p3',
|
|
||||||
'autoResize':true,
|
|
||||||
'height':'577',
|
|
||||||
'async':true,
|
|
||||||
'header':'show'};
|
|
||||||
s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'wufoo.com/scripts/embed/form.js';
|
|
||||||
s.onload = s.onreadystatechange = function() {
|
|
||||||
var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return;
|
|
||||||
try { z7x3p3 = new WufooForm();z7x3p3.initialize(options);z7x3p3.display(); } catch (e) {}};
|
|
||||||
var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr);
|
|
||||||
})(document, 'script');</script>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://si0.twimg.com/profile_images/2707460527/252a64411a339184ff375a96fb68dcb0_bigger.png">
|
|
||||||
<em>Mitchell Hashimoto @mitchellh:</em> Docker launched today. It is incredible. They’re also working RIGHT NOW on a Vagrant provider. LXC is COMING!!
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://si0.twimg.com/profile_images/1108290260/Adam_Jacob-114x150_original_bigger.jpg">
|
|
||||||
<em>Adam Jacob @adamhjk:</em> Docker is clearly the right idea. @solomonstre absolutely killed it. Containerized app deployment is the future, I think.
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://si0.twimg.com/profile_images/14872832/twitter_pic_bigger.jpg">
|
|
||||||
<em>Matt Townsend @mtownsend:</em> I have a serious code crush on docker.io - it's Lego for PaaS. Motherfucking awesome Lego.
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://si0.twimg.com/profile_images/1312352395/rupert-259x300_bigger.jpg">
|
|
||||||
<em>Rob Harrop @robertharrop:</em> Impressed by @getdocker - it's all kinds of magic. Serious rethink of AWS architecture happening @skillsmatter.
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://twimg0-a.akamaihd.net/profile_images/2491994496/rbevyyq6ykp6bnoby2je_bigger.jpeg">
|
|
||||||
<em>John Willis @botchagalupe:</em> IMHO docker is to paas what chef was to Iaas 4 years ago
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://twimg0-a.akamaihd.net/profile_images/3348427561/9d7f08f1e103a16c8debd169301b9944_bigger.jpeg">
|
|
||||||
<em>John Feminella @superninjarobot:</em> So, @getdocker is pure excellence. If you've ever wished for arbitrary, PaaS-agnostic, lxc/aufs Linux containers, this is your jam!
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://si0.twimg.com/profile_images/3408403010/4496ccdd14e9b7285eca04c31a740207_bigger.jpeg">
|
|
||||||
<em>David Romulan @destructuring:</em> I haven't had this much fun since AWS
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="span6">
|
|
||||||
<section class="contentblock twitterblock">
|
|
||||||
<img src="https://si0.twimg.com/profile_images/780893320/My_Avatar_bigger.jpg">
|
|
||||||
<em>Ricardo Gladwell @rgladwell:</em> wow @getdocker is either amazing or totally stupid
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="span6">
|
|
||||||
|
|
||||||
<section class="contentblock">
|
|
||||||
|
|
||||||
<h2>Notable features</h2>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Filesystem isolation: each process container runs in a completely separate root filesystem.</li>
|
|
||||||
<li>Resource isolation: system resources like cpu and memory can be allocated differently to each process container, using cgroups.</li>
|
|
||||||
<li>Network isolation: each process container runs in its own network namespace, with a virtual interface and IP address of its own.</li>
|
|
||||||
<li>Copy-on-write: root filesystems are created using copy-on-write, which makes deployment extremely fast, memory-cheap and disk-cheap.</li>
|
|
||||||
<li>Logging: the standard streams (stdout/stderr/stdin) of each process container is collected and logged for real-time or batch retrieval.</li>
|
|
||||||
<li>Change management: changes to a container's filesystem can be committed into a new image and re-used to create more containers. No templating or manual configuration required.</li>
|
|
||||||
<li>Interactive shell: docker can allocate a pseudo-tty and attach to the standard input of any container, for example to run a throwaway interactive shell.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h2>Under the hood</h2>
|
|
||||||
|
|
||||||
<p>Under the hood, Docker is built on the following components:</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>The <a href="http://blog.dotcloud.com/kernel-secrets-from-the-paas-garage-part-24-c">cgroup</a> and <a href="http://blog.dotcloud.com/under-the-hood-linux-kernels-on-dotcloud-part">namespacing</a> capabilities of the Linux kernel;</li>
|
|
||||||
<li><a href="http://aufs.sourceforge.net/aufs.html">AUFS</a>, a powerful union filesystem with copy-on-write capabilities;</li>
|
|
||||||
<li>The <a href="http://golang.org">Go</a> programming language;</li>
|
|
||||||
<li><a href="http://lxc.sourceforge.net/">lxc</a>, a set of convenience scripts to simplify the creation of linux containers.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h2>Who started it</h2>
|
|
||||||
<p>
|
|
||||||
Docker is an open-source implementation of the deployment engine which powers <a href="http://dotcloud.com">dotCloud</a>, a popular Platform-as-a-Service.</p>
|
|
||||||
|
|
||||||
<p>It benefits directly from the experience accumulated over several years of large-scale operation and support of hundreds of thousands
|
|
||||||
of applications and databases.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="span6">
|
|
||||||
|
|
||||||
|
|
||||||
<section class="contentblock">
|
|
||||||
<h3 id="twitter">Twitter</h3>
|
|
||||||
<a class="twitter-timeline" href="https://twitter.com/getdocker" data-widget-id="312730839718957056">Tweets by @getdocker</a>
|
|
||||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div> <!-- end container -->
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
<footer id="footer" class="footer">
|
|
||||||
<div class="row">
|
|
||||||
<div class="span12">
|
|
||||||
<div class="tbox textright forceleftmargin social links pull-right">
|
|
||||||
<a class="twitter" href="http://twitter.com/getdocker">Twitter</a>
|
|
||||||
<a class="github" href="https://github.com/dotcloud/docker/">GitHub</a>
|
|
||||||
</div>
|
|
||||||
Docker is a project by <a href="http://www.dotcloud.com">dotCloud</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="emptyspace" style="height: 40px">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- bootstrap javascipts -->
|
|
||||||
<script src="static/js/vendor/bootstrap.min.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
<!-- Google analytics -->
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
var _gaq = _gaq || [];
|
|
||||||
_gaq.push(['_setAccount', 'UA-6096819-11']);
|
|
||||||
_gaq.push(['_setDomainName', 'docker.io']);
|
|
||||||
_gaq.push(['_setAllowLinker', true]);
|
|
||||||
_gaq.push(['_trackPageview']);
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
# rule to redirect original links created when hosted on github pages
|
|
||||||
rewrite ^/documentation/(.*).html http://docs.docker.io/en/latest/$1/ permanent;
|
|
||||||
|
|
||||||
# rewrite the stuff which was on the current page
|
|
||||||
rewrite ^/gettingstarted.html$ /gettingstarted/ permanent;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../theme/docker/static
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package docker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/dotcloud/docker/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getKernelVersion() (*utils.KernelVersionInfo, error) {
|
|
||||||
return nil, fmt.Errorf("Kernel version detection is not available on darwin")
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package docker
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"github.com/dotcloud/docker/utils"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// FIXME: Move this to utils package
|
|
||||||
func getKernelVersion() (*utils.KernelVersionInfo, error) {
|
|
||||||
var (
|
|
||||||
uts syscall.Utsname
|
|
||||||
flavor string
|
|
||||||
kernel, major, minor int
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := syscall.Uname(&uts); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
release := make([]byte, len(uts.Release))
|
|
||||||
|
|
||||||
i := 0
|
|
||||||
for _, c := range uts.Release {
|
|
||||||
release[i] = byte(c)
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the \x00 from the release for Atoi to parse correctly
|
|
||||||
release = release[:bytes.IndexByte(release, 0)]
|
|
||||||
|
|
||||||
tmp := strings.SplitN(string(release), "-", 2)
|
|
||||||
tmp2 := strings.SplitN(tmp[0], ".", 3)
|
|
||||||
|
|
||||||
if len(tmp2) > 0 {
|
|
||||||
kernel, err = strconv.Atoi(tmp2[0])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(tmp2) > 1 {
|
|
||||||
major, err = strconv.Atoi(tmp2[1])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(tmp2) > 2 {
|
|
||||||
minor, err = strconv.Atoi(tmp2[2])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(tmp) == 2 {
|
|
||||||
flavor = tmp[1]
|
|
||||||
} else {
|
|
||||||
flavor = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return &utils.KernelVersionInfo{
|
|
||||||
Kernel: kernel,
|
|
||||||
Major: major,
|
|
||||||
Minor: minor,
|
|
||||||
Flavor: flavor,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
@@ -162,7 +162,7 @@ func (graph *Graph) Register(layerData Archive, store bool, img *Image) error {
|
|||||||
// The archive is stored on disk and will be automatically deleted as soon as has been read.
|
// The archive is stored on disk and will be automatically deleted as soon as has been read.
|
||||||
// If output is not nil, a human-readable progress bar will be written to it.
|
// If output is not nil, a human-readable progress bar will be written to it.
|
||||||
// FIXME: does this belong in Graph? How about MktempFile, let the caller use it for archives?
|
// FIXME: does this belong in Graph? How about MktempFile, let the caller use it for archives?
|
||||||
func (graph *Graph) TempLayerArchive(id string, compression Compression, output io.Writer) (*TempArchive, error) {
|
func (graph *Graph) TempLayerArchive(id string, compression Compression, sf *utils.StreamFormatter, output io.Writer) (*TempArchive, error) {
|
||||||
image, err := graph.Get(id)
|
image, err := graph.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -175,7 +175,6 @@ func (graph *Graph) TempLayerArchive(id string, compression Compression, output
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sf := utils.NewStreamFormatter(false)
|
|
||||||
return NewTempArchive(utils.ProgressReader(ioutil.NopCloser(archive), 0, output, sf.FormatProgress("Buffering to disk", "%v/%v (%v)"), sf), tmp.Root)
|
return NewTempArchive(utils.ProgressReader(ioutil.NopCloser(archive), 0, output, sf.FormatProgress("Buffering to disk", "%v/%v (%v)"), sf), tmp.Root)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,7 +188,7 @@ func (graph *Graph) Mktemp(id string) (string, error) {
|
|||||||
return "", fmt.Errorf("Couldn't create temp: %s", err)
|
return "", fmt.Errorf("Couldn't create temp: %s", err)
|
||||||
}
|
}
|
||||||
if tmp.Exists(id) {
|
if tmp.Exists(id) {
|
||||||
return "", fmt.Errorf("Image %d already exists", id)
|
return "", fmt.Errorf("Image %s already exists", id)
|
||||||
}
|
}
|
||||||
return tmp.imageRoot(id), nil
|
return tmp.imageRoot(id), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,11 +192,19 @@ func TestDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assertNImages(graph, t, 0)
|
assertNImages(graph, t, 0)
|
||||||
|
|
||||||
|
archive, err = fakeTar()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
// Test 2 create (same name) / 1 delete
|
// Test 2 create (same name) / 1 delete
|
||||||
img1, err := graph.Create(archive, nil, "Testing", "", nil)
|
img1, err := graph.Create(archive, nil, "Testing", "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
archive, err = fakeTar()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
if _, err = graph.Create(archive, nil, "Testing", "", nil); err != nil {
|
if _, err = graph.Create(archive, nil, "Testing", "", nil); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -212,6 +220,10 @@ func TestDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assertNImages(graph, t, 1)
|
assertNImages(graph, t, 1)
|
||||||
|
|
||||||
|
archive, err = fakeTar()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
// Test delete twice (pull -> rm -> pull -> rm)
|
// Test delete twice (pull -> rm -> pull -> rm)
|
||||||
if err := graph.Register(archive, false, img1); err != nil {
|
if err := graph.Register(archive, false, img1); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ This directory contains material helpful for hacking on docker.
|
|||||||
make hack
|
make hack
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Set up an Ubuntu 13.04 virtual machine for developers including kernel 3.8
|
Set up an Ubuntu 12.04 virtual machine for developers including kernel 3.8
|
||||||
and buildbot. The environment is setup in a way that can be used through
|
go1.1 and buildbot. The environment is setup in a way that can be used through
|
||||||
the usual go workflow and/or the root Makefile. You can either edit on
|
the usual go workflow and/or the root Makefile. You can either edit on
|
||||||
your host, or inside the VM (using make ssh-dev) and run and test docker
|
your host, or inside the VM (using make ssh-dev) and run and test docker
|
||||||
inside the VM.
|
inside the VM.
|
||||||
@@ -22,6 +22,7 @@ developers are inconvenienced by the failure.
|
|||||||
|
|
||||||
When running 'make hack' at the docker root directory, it spawns a virtual
|
When running 'make hack' at the docker root directory, it spawns a virtual
|
||||||
machine in the background running a buildbot instance and adds a git
|
machine in the background running a buildbot instance and adds a git
|
||||||
post-commit hook that automatically run docker tests for you.
|
post-commit hook that automatically run docker tests for you each time you
|
||||||
|
commit in your local docker repository.
|
||||||
|
|
||||||
You can check your buildbot instance at http://192.168.33.21:8010/waterfall
|
You can check your buildbot instance at http://192.168.33.21:8010/waterfall
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
## A maintainer's guide to releasing Docker
|
||||||
|
|
||||||
|
So you're in charge of a docker release? Cool. Here's what to do.
|
||||||
|
|
||||||
|
If your experience deviates from this document, please document the changes to keep it
|
||||||
|
up-to-date.
|
||||||
|
|
||||||
|
|
||||||
|
### 1. Pull from master and create a release branch
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git checkout master
|
||||||
|
$ git pull
|
||||||
|
$ git checkout -b bump_$VERSION
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Update CHANGELOG.md
|
||||||
|
|
||||||
|
You can run this command for reference:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LAST_VERSION=$(git tag | grep -E "v[0-9\.]+$" | sort -nr | head -n 1)
|
||||||
|
git log $LAST_VERSION..HEAD
|
||||||
|
```
|
||||||
|
|
||||||
|
Each change should be formatted as ```BULLET CATEGORY: DESCRIPTION```
|
||||||
|
|
||||||
|
* BULLET is either ```-```, ```+``` or ```*```, to indicate a bugfix,
|
||||||
|
new feature or upgrade, respectively.
|
||||||
|
|
||||||
|
* CATEGORY should describe which part of the project is affected.
|
||||||
|
Valid categories are:
|
||||||
|
* Builder
|
||||||
|
* Documentation
|
||||||
|
* Hack
|
||||||
|
* Packaging
|
||||||
|
* Remote API
|
||||||
|
* Runtime
|
||||||
|
|
||||||
|
* DESCRIPTION: a concise description of the change that is relevant to the end-user,
|
||||||
|
using the present tense.
|
||||||
|
Changes should be described in terms of how they affect the user, for example "new feature
|
||||||
|
X which allows Y", "fixed bug which caused X", "increased performance of Y".
|
||||||
|
|
||||||
|
EXAMPLES:
|
||||||
|
|
||||||
|
```
|
||||||
|
+ Builder: 'docker build -t FOO' applies the tag FOO to the newly built container.
|
||||||
|
* Runtime: improve detection of kernel version
|
||||||
|
- Remote API: fix a bug in the optional unix socket transport
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Change VERSION in commands.go
|
||||||
|
|
||||||
|
### 4. Run all tests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ make test
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Commit and create a pull request
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git add commands.go CHANGELOG.md
|
||||||
|
$ git commit -m "Bump version to $VERSION"
|
||||||
|
$ git push origin bump_$VERSION
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Get 2 other maintainers to validate the pull request
|
||||||
|
|
||||||
|
### 7. Merge the pull request and apply tags
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git checkout master
|
||||||
|
$ git merge bump_$VERSION
|
||||||
|
$ git tag -a v$VERSION # Don't forget the v!
|
||||||
|
$ git tag -f -a latest
|
||||||
|
$ git push
|
||||||
|
$ git push --tags
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8. Publish binaries
|
||||||
|
|
||||||
|
To run this you will need access to the release credentials.
|
||||||
|
Get them from [the infrastructure maintainers](https://github.com/dotcloud/docker/blob/master/hack/infrastructure/MAINTAINERS).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ RELEASE_IMAGE=image_provided_by_infrastructure_maintainers
|
||||||
|
$ BUILD=$(docker run -d -e RELEASE_PPA=0 $RELEASE_IMAGE)
|
||||||
|
```
|
||||||
|
|
||||||
|
This will do 2 things:
|
||||||
|
|
||||||
|
* It will build and upload the binaries on http://get.docker.io
|
||||||
|
* It will *test* the release on our Ubuntu PPA (a PPA is a community repository for ubuntu packages)
|
||||||
|
|
||||||
|
Wait for the build to complete.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker wait $BUILD # This should print 0. If it doesn't, your build failed.
|
||||||
|
```
|
||||||
|
|
||||||
|
Check that the output looks OK. Here's an example of a correct output:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker logs 2>&1 b4e7c8299d73 | grep -e 'Public URL' -e 'Successfully uploaded'
|
||||||
|
Public URL of the object is: http://get.docker.io.s3.amazonaws.com/builds/Linux/x86_64/docker-v0.4.7.tgz
|
||||||
|
Public URL of the object is: http://get.docker.io.s3.amazonaws.com/builds/Linux/x86_64/docker-latest.tgz
|
||||||
|
Successfully uploaded packages.
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't see 3 lines similar to this, something might be wrong. Check the full logs and try again.
|
||||||
|
|
||||||
|
|
||||||
|
### 9. Publish Ubuntu packages
|
||||||
|
|
||||||
|
If everything went well in the previous step, you can finalize the release by submitting the Ubuntu
|
||||||
|
packages.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ RELEASE_IMAGE=image_provided_by_infrastructure_maintainers
|
||||||
|
$ docker run -e RELEASE_PPA=1 $RELEASE_IMAGE
|
||||||
|
```
|
||||||
|
|
||||||
|
If that goes well, Ubuntu Precise package is in its way. It will take anywhere from 0.5 to 30 hours
|
||||||
|
for the builders to complete their job depending on builder demand at this time. At this point, Quantal
|
||||||
|
and Raring packages need to be created using the Launchpad interface:
|
||||||
|
https://launchpad.net/~dotcloud/+archive/lxc-docker/+packages
|
||||||
|
|
||||||
|
Notify [the packager maintainers](https://github.com/dotcloud/docker/blob/master/packaging/MAINTAINERS)
|
||||||
|
who will ensure PPA is ready.
|
||||||
|
|
||||||
|
Congratulations! You're done
|
||||||