309 Commits
v0.1 ... v0.6

Author SHA1 Message Date
Baohua Yang
e2544bcb28 release 0.6 2015-12-24 09:44:47 +08:00
yeasy
121f498011 Merge pull request #80 from LcpMarvel/image_create_text
fix image building description on installing the json application
2015-12-21 09:27:45 +08:00
lcp
7d9625ec25 修正镜像创建中json应用描述 2015-12-19 12:13:18 +08:00
yeasy
3ca35d9638 Merge pull request #79 from GameXG/master
fix path error in compose example
2015-12-16 11:31:38 +08:00
GameXG
c71cf6a731 修正 compose 例子错误
数据卷相对路径必须以 . 或 .. 开头,否则会被认为是卷名称,由于存在 “/” 会提示:ERROR: haproxy/haproxy.cfg includes invalid characters for a local volume name, only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed 

参考来源:https://docs.docker.com/compose/compose-file/
You can mount a relative path on the host, which will expand relative to the directory of the Compose configuration file being used. Relative paths should always begin with . or ...
2015-11-26 22:41:28 +08:00
yeasy
062f008435 Merge pull request #77 from rhinoceros/master
Resolve apache2 install dependency error
2015-10-14 13:19:43 +08:00
rhinoceros.xn
6158dda40e Update case/supervisor.md : Resolve apache2 install error
Resolve error below:


Step 5 : RUN apt-get install -y openssh-server apache2 supervisor
 ---> Running in 816b405cf0d1
Reading package lists...
Building dependency tree...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 apache2 : Depends: apache2-mpm-worker (= 2.2.22-1ubuntu1) but it is not going to be installed or
                    apache2-mpm-prefork (= 2.2.22-1ubuntu1) but it is not going to be installed or
                    apache2-mpm-event (= 2.2.22-1ubuntu1) but it is not going to be installed or
                    apache2-mpm-itk (= 2.2.22-1ubuntu1) but it is not going to be installed
           Depends: apache2.2-common (= 2.2.22-1ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c apt-get install -y openssh-server apache2 supervisor' returned a non-zero code: 100
2015-10-13 13:53:05 +08:00
yeasy
692db8b6a2 Merge pull request #76 from zhangbaitong/master
Add coreos cluster quickstart section
2015-09-28 17:41:00 +08:00
zhangbaitong
3291d4795f coreos cluster quickstart section 2015-09-28 17:33:45 +08:00
yeasy
bfecf409ea Merge pull request #75 from zhangbaitong/master
Add coreos tools intro section
2015-09-28 15:15:02 +08:00
zhangbaitong
eb32546e3c coreos tools intro section 2015-09-28 11:43:40 +08:00
yeasy
cd59aaf167 Merge pull request #73 from zhangbaitong/master
Add coreos intro section
2015-09-06 08:58:22 +08:00
zhangbaitong
6066e9cc5a coreos intro 2015-09-06 08:50:13 +08:00
yeasy
4d60922fa3 Merge pull request #72 from dayiguizhen/patch-4
use -d to boot contianer
2015-08-28 17:55:33 +08:00
dayiguizhen
14fddb18be Update usage.md
更改加入集群的参数命令
2015-08-26 13:24:48 +08:00
yeasy
0dfe3ebcce Merge pull request #71 from dayiguizhen/patch-3
Fix swarm starting missing flag
2015-08-25 13:57:10 +08:00
dayiguizhen
99df02f626 Update usage.md
修改swarm加入集群的参数
2015-08-25 13:53:02 +08:00
yeasy
0a4bd48a79 Merge pull request #70 from dayiguizhen/patch-2
Update the figure url
2015-08-25 10:36:36 +08:00
dayiguizhen
9956994b76 Update intro.md
修改图片的地址
2015-08-25 10:32:53 +08:00
yeasy
e564a7d4da Merge pull request #69 from ChaoMai/master
Fix issue #68: Add missing -d flag to run container in background
2015-08-18 10:20:46 +08:00
Chao Mai
950dadf54d Fix issue #68: 在5.2 守护状态运行中,命令错误 2015-08-18 10:07:45 +08:00
yeasy
a7d45c5a16 Merge pull request #67 from dayiguizhen/patch-1
Update daemon.md
2015-08-03 10:08:32 +08:00
dayiguizhen
a435453b80 Update daemon.md
docker run -d 的含义是在后台运行容器并且输出容器的ID(Run container in background and print container ID),而不是以守护态运行容器。
2015-08-02 15:43:04 +08:00
Baohua Yang
5ba3d7b007 Merge branch 'master' of github.com:yeasy/docker_practice 2015-07-16 15:35:13 +08:00
Baohua Yang
bace19fdc0 Add more details on docker machine 2015-07-16 15:34:54 +08:00
Baohua Yang
76d8382136 reformat 2015-07-16 14:26:47 +08:00
Baohua Yang
17ecc5d33d Replace compose logo with latest version 2015-07-16 14:26:23 +08:00
yeasy
8043983d75 Merge pull request #66 from dayiguizhen/patch-1
fix link with http prefix
2015-07-15 16:14:46 +08:00
dayiguizhen
28c1490fc6 如果是docker.com是打不开的
会转到下面这个链接。
https://github.com/yeasy/docker_practice/blob/master/docker.com
2015-07-15 16:11:46 +08:00
Baohua Yang
f633c14de3 Fix issue#64, duplicated words 2015-07-07 11:08:58 +08:00
yeasy
f026a1bee0 Merge pull request #62 from jzk/cleanup
add commands to cleanup unused containers and images
2015-07-05 10:37:31 +08:00
yeasy
e0d2d0997f Merge pull request #61 from jzk/datavolume
Data volume expression revise.
2015-07-05 10:36:04 +08:00
Zhenkai Jiang
60ec1bf62c add sections to cleanup unused containers and images 2015-07-03 16:52:47 +08:00
Zhenkai Jiang
977221c5d1 add an example to validate restored data from data volume container 2015-07-03 16:23:46 +08:00
Zhenkai Jiang
72144f1032 fix a few vague descriptions for data volumes containers and backup/restore 2015-07-03 16:19:51 +08:00
Zhenkai Jiang
62aa90a3bf add/correct lifecycle information for data volumes 2015-07-03 16:17:28 +08:00
Baohua Yang
94c15606b3 Add mesos framework 2015-06-30 17:11:45 +08:00
Baohua Yang
215a5dec0b Add mesos chapter 2015-06-29 18:20:31 +08:00
Baohua Yang
2a6620036f Add the architecture design for k8s 2015-06-08 11:19:52 +08:00
Baohua Yang
c5a5656220 Refine the kubernetes chapter's structure 2015-06-08 10:51:42 +08:00
Baohua Yang
0e87b70fbf Add the section of kubectl, to be filled 2015-06-08 10:32:13 +08:00
Baohua Yang
03b1d1ffc0 Add the kubernetes quickstart 2015-06-08 10:26:08 +08:00
yeasy
eb6683fbd7 Merge pull request #60 from maguowei/master
format the expression
2015-06-07 22:36:02 +08:00
maguowei
345b0703a3 format text 2015-06-07 21:27:32 +08:00
Baohua Yang
7f4e4145b0 Fix content formatting and typos 2015-05-21 20:23:53 +08:00
Baohua Yang
c814568560 Split out the swarm scheduling and filter sections 2015-05-21 19:57:58 +08:00
yeasy
4cb1252a98 Merge pull request #59 from rio-2607/rio-docker-practice
Add the content for the docker-swarm project
2015-05-21 19:47:41 +08:00
rio-2607
a2231978ab Update usage.md 2015-05-21 19:36:59 +08:00
rio-2607
a3ca178621 Update usage.md 2015-05-20 21:56:41 +08:00
rio-2607
0b607e92a2 Update usage.md 2015-05-20 20:48:11 +08:00
rio-2607
29fcb84407 Update usage.md 2015-05-20 20:44:19 +08:00
rio-2607
d457323780 Update usage.md 2015-05-19 21:32:15 +08:00
rio-2607
f9c545dbfc update usage.md 2015-05-19 19:58:04 +08:00
rio-2607
ed893bea7e update intro.md 2015-05-18 21:24:13 +08:00
rio-2607
295b7cdb7f Update install.md 2015-05-18 20:24:14 +08:00
rio-2607
e4e3cca8d3 update install.md 2015-05-18 20:23:38 +08:00
yeasy
34a3c29865 Merge pull request #58 from UncleBarney/patch-1
Correct supervisor container name
2015-05-14 19:48:23 +08:00
Hechen Gao
b30d4a2328 Correct supervisor container name
The name of the container for configured supervisord container is incorrect.
It was: test/supervisords, while in the build step, we tagged it as test/supervisor.
2015-05-13 15:38:49 -07:00
Baohua Yang
5f59530d4c Add compose quick start example 2015-05-11 14:46:51 +08:00
Baohua Yang
52a1755ce7 Add more options for compose yaml file 2015-05-10 14:56:05 +08:00
Baohua Yang
547ebe6053 Start the swarm chapter 2015-05-08 20:10:44 +08:00
Baohua Yang
fdeeaba0b0 Start the machine chapter 2015-05-08 20:10:34 +08:00
Baohua Yang
8626d13738 Add the compose chapter 2015-05-08 20:10:01 +08:00
yeasy
36127abed9 Merge pull request #57 from milhu/patch-1
Update .bashrc_docker for CentOS usage
2015-05-08 13:12:28 +08:00
milhu
8e976258b5 Update .bashrc_docker for CentOS usage
resolve invalid option error and able to find nsenter automatically if it has been installed with path notified
2015-05-08 11:21:02 +08:00
Baohua Yang
1d864385af Change version number to 0.4 2015-05-08 10:47:47 +08:00
yeasy
068e2e948b Merge pull request #56 from tekkamanninja/tekkaman_fix
Fix typo in container/import_export.md:
2015-05-04 11:21:25 +08:00
Fu Wei
d61a0b7677 Fix typo in container/import_export.md:
test/buntu:v1.0 to test/ubuntu:v1.0
2015-04-27 15:46:37 +08:00
yeasy
da6bb5f174 Merge pull request #51 from custa/master
Fix typos and expression format.
2015-03-15 19:17:40 +08:00
custa
fd92e6e343 Update tomcat.md
排版错误
2015-03-12 16:36:11 +08:00
custa
39cb5ffa88 放到
错别字: 方到 -> 放到
2015-03-12 16:18:35 +08:00
custa
b66e84fb84 Update supervisor.md
### 安装 ssh、apache 和 supervisor
2015-03-12 16:17:18 +08:00
Baohua Yang
72f6c252be Remove useless files 2015-03-12 13:41:02 +08:00
Baohua Yang
1b576a7e2a Add the kubernetes chapter into summary 2015-03-12 13:32:39 +08:00
yeasy
dee055b261 Merge pull request #50 from custa/master
修改错别字:容器卷->数据卷
2015-03-12 13:22:58 +08:00
custa
9df06628d2 Update linking.md 2015-03-11 09:52:45 +08:00
custa
c1844c1345 Update container.md 2015-03-11 09:48:35 +08:00
waitfish
53b75686d7 Change QQ 2015-02-28 16:11:54 +08:00
yeasy
d43fefff44 Merge pull request #48 from weilaihui/master
kubernetes写到第二节
2015-02-26 20:54:38 +08:00
yeasy
d4b2e6bee8 Merge pull request #47 from you-n-g/master
Fix simple typo
2015-02-26 20:53:41 +08:00
xiaolinzi
2fc168142c 复制控制器 2015-02-26 18:16:08 +08:00
xiaolinzi
c06250ee20 kubernetes写到第二节 2015-02-26 18:16:08 +08:00
xiaolinzi
815aca0279 readme done 2015-02-26 18:16:08 +08:00
xiaolin
1c194b4738 test 2015-02-26 18:16:08 +08:00
Young Yang
6b1a7e5028 simple typo 2015-02-23 10:25:27 +08:00
yeasy
939af1884a Merge pull request #46 from you-n-g/master
just a simple type error
2015-02-21 13:21:04 +08:00
Young Yang
76fcc36ac9 just a simple type error 2015-02-12 22:48:10 +08:00
yeasy
6fb92461c4 Merge pull request #45 from zhangbaitong/master
fix url format
2015-02-12 14:01:32 +08:00
zhangbaitong
86a4b061b0 fix url format 2015-02-12 13:42:06 +08:00
yeasy
cba7c8017e Merge pull request #44 from zhangbaitong/master
fix url format
2015-02-12 12:04:46 +08:00
zhangbaitong
b7ed0ab7a4 fix url format 2015-02-12 11:56:29 +08:00
yeasy
7a87084d71 Update README.md
v0.3.4
2015-02-03 13:48:47 +08:00
yeasy
6375778e23 Merge pull request #41 from zhangbaitong/master
add CoreOS section
2015-01-31 12:56:18 +08:00
zhangbaitong
bf63c11c05 add coreos section 2015-01-31 12:47:27 +08:00
zhangbaitong
7cd6a94dc4 add coreos section 2015-01-31 12:43:20 +08:00
yeasy
b445841df7 Merge pull request #40 from copuzzle/master
Fix expression words.
2015-01-22 10:30:32 +08:00
copuzzle
fa9d217607 修改一些小细节 2015-01-21 22:20:03 +08:00
copuzzle
60d1e6f20d Merge branch 'master' of https://github.com/yeasy/docker_practice 2015-01-21 21:42:01 +08:00
yeasy
340af53f10 Merge pull request #39 from stamhe/master
Fix typos.
2015-01-20 19:34:33 +08:00
Stam He
4fff004b97 修改笔误 2015-01-20 15:26:33 +08:00
copuzzle
7ea165b3b4 暴漏 to 暴露 2015-01-15 20:47:16 +08:00
yeasy
842a81eb1c Merge pull request #38 from zhangbaitong/master
finished fig env ref
2015-01-15 10:25:48 +08:00
zhangbaitong
ff130ef077 finished fig env ref 2015-01-15 10:18:12 +08:00
zhangbaitong
57f53c031b finished fig env ref 2015-01-15 10:17:25 +08:00
yeasy
92925d2cb3 Merge pull request #37 from zhangbaitong/master
finished fig.yml ref
2015-01-15 08:37:59 +08:00
zhangbaitong
b424142791 finished fig.yml ref 2015-01-14 23:26:04 +08:00
zhangbaitong
8d40f74532 finished fig.yml ref 2015-01-14 23:22:04 +08:00
yeasy
285d69275a Merge pull request #35 from zhangbaitong/master
fix url address
2015-01-14 23:08:27 +08:00
zhangbaitong
34282977af use right format of md 2015-01-14 22:48:33 +08:00
zhangbaitong
42ca51db65 use right format of md 2015-01-14 22:45:59 +08:00
Baohua Yang
dd02308d91 Update summary to add recent content 2015-01-14 22:45:23 +08:00
yeasy
2da8779e68 Merge pull request #36 from copuzzle/master
Finish django rails wordpress chapters
2015-01-14 22:38:43 +08:00
copuzzle
e8607564a4 finished wordpress 2015-01-14 21:52:19 +08:00
copuzzle
753130f571 add wordpress content 2015-01-14 14:09:38 +08:00
copuzzle
9c5053b89c finished rails basicly 2015-01-14 13:46:21 +08:00
copuzzle
1cbd9645fc 修改句子 2015-01-14 10:51:02 +08:00
copuzzle
d473dabd78 finished django,add ml_ref.md 2015-01-14 10:03:47 +08:00
zhangbaitong
b0a61fb009 修改错别字 2015-01-14 09:29:16 +08:00
zhangbaitong
6f3898ae6b fix url address 2015-01-14 09:05:41 +08:00
copuzzle
7ccfec3f3b add django rails file and other images 2015-01-13 18:04:53 +08:00
yeasy
63264c623c Merge pull request #34 from zhangbaitong/master
update summary for fig cli chapter
2015-01-13 16:20:00 +08:00
zhangbaitong
8261449e42 update fig cli ref doc 2015-01-13 16:13:30 +08:00
yeasy
9a6bc4a1aa Merge pull request #33 from zhangbaitong/master
补充句子中遗留的命令
2015-01-13 16:10:22 +08:00
zhangbaitong
42785a15a7 add fig cli ref doc 2015-01-13 16:05:00 +08:00
zhangbaitong
d044ff923a 修改格式 2015-01-12 10:16:14 +08:00
zhangbaitong
e55429f64f 补充句子中遗留的命令 2015-01-11 21:47:22 +08:00
yeasy
69e0cc2c26 Merge pull request #30 from zhangbaitong/master
修改fig章节表述内容
2015-01-11 19:40:07 +08:00
zhangbaitong
94d7e664c3 修改内容表述问题 2015-01-07 15:55:00 +08:00
zhangbaitong
14cad7881f 修改错误表述内容 2015-01-07 14:03:12 +08:00
Baohua Yang
a93f3b4d2a Add the fig chapter into summary 2015-01-04 18:19:38 +08:00
yeasy
c5fd5f025c Merge pull request #29 from copuzzle/master
Fig 文档翻译, 简介,首页,安装章节
2015-01-04 17:57:06 +08:00
copuzzle
f80eed0e18 fix char 2015-01-01 22:21:30 +08:00
copuzzle
d2bbf9e4ca fix error char 2015-01-01 22:17:39 +08:00
copuzzle
544ee1de65 finish install section 2015-01-01 22:12:28 +08:00
copuzzle
8956a6b120 Merge branch 'master' of https://github.com/yeasy/docker_practice 2015-01-01 21:23:55 +08:00
copuzzle
36b6e29d59 add readme content
fix warring tag css
2015-01-01 21:21:33 +08:00
copuzzle
fbe187a743 fix image problem 2015-01-01 12:16:46 +08:00
Baohua Yang
971023ddca Minor change words 2014-12-31 18:32:46 +08:00
Baohua Yang
a977601251 Update version info in the preface content 2014-12-31 17:20:26 +08:00
Baohua Yang
589148450f Add etcd chapter 2014-12-31 17:11:09 +08:00
Baohua Yang
29b7568853 Start v0.4 writing, minor fix preface content 2014-12-31 10:08:27 +08:00
copuzzle
69d10ac09d fix som problem 2014-12-30 23:57:43 +08:00
copuzzle
c0dbca7a93 finish home page translate 2014-12-30 23:44:09 +08:00
copuzzle
dd24811386 add fig doc part 2014-12-30 14:46:50 +08:00
Baohua Yang
2392ba87ea Add links to china-pub 2014-12-22 09:47:00 +08:00
Baohua Yang
d4d430a99e Fix issue #28: maintainer information 2014-12-21 19:27:46 +08:00
Baohua Yang
201a2180a3 Merge branch 'master' of github.com:yeasy/docker_practice 2014-12-21 19:24:45 +08:00
Baohua Yang
070359c511 Refine the preface content 2014-12-21 19:24:20 +08:00
yeasy
7876ec1485 Merge pull request #27 from gaojice/master
试试如何贡献
2014-12-14 11:41:05 +08:00
gaojice
f945d9f209 试试如何贡献 2014-12-13 00:16:10 +08:00
Baohua Yang
9215e4b88e Publish v0.3 version 2014-11-25 13:38:43 +08:00
Baohua Yang
e5a297a7be Update ignore type list 2014-11-07 15:42:25 +08:00
Baohua Yang
34dc895942 Merge branch 'master' of github.com:yeasy/docker_practice 2014-11-07 15:27:30 +08:00
yeasy
d858b810be Merge pull request #22 from yougg/patch-1
修改部分错别字及描述信息
2014-11-06 20:34:49 +08:00
yougg
76b6a51f57 修改标点符号 2014-11-06 10:58:28 +08:00
yougg
6af4bdd1d1 修改错别字 2014-11-06 10:41:26 +08:00
yougg
8a7c23ce01 添加URL链接 2014-11-06 10:32:09 +08:00
yougg
089533127f 修改错别字 2014-11-06 10:28:19 +08:00
yougg
d0297f8da6 修改错别字 2014-11-06 10:19:56 +08:00
yougg
fb3ba14bdf 删除多余字 2014-11-06 10:16:10 +08:00
yougg
f9bdf3fe89 修改语句描述 2014-11-06 10:00:36 +08:00
yougg
6e9dea1ffe 修改"虚拟机"为"容器" 2014-11-06 09:47:21 +08:00
yougg
d7c88f7972 添加标题标记 2014-11-06 09:14:51 +08:00
yougg
05eb51961d 添加遗漏字 2014-11-06 09:06:49 +08:00
yougg
5fc06666c8 修改错别字 2014-11-05 17:37:37 +08:00
yougg
af2a0b28c5 修改语句描述
修改语句描述
2014-11-05 12:47:29 +08:00
Baohua Yang
fda6a07a1e Minor update ignore file; Add pull_all and push_all scripts 2014-10-30 15:30:51 +08:00
yeasy
f936efebd9 Update push_images.sh 2014-10-26 15:36:52 +08:00
Baohua Yang
16527880fb minor fix space; delete useless file 2014-10-21 13:59:03 +08:00
Baohua Yang
cb903202ba Fix issue#20, format following the guidelines 2014-10-14 13:25:01 +08:00
Baohua Yang
9d26f96ba2 Merge branch 'master' of github.com:yeasy/docker_practice 2014-10-12 10:32:14 +08:00
Baohua Yang
ed7c2a3ee7 User new dockerpool repo server address 2014-10-12 10:32:04 +08:00
Baohua Yang
894d8ebc62 Merge pull request #19 from luashiping/master
fix expose
2014-10-11 16:35:58 +08:00
lushiping
46195eb9f6 fix expose 2014-10-11 16:18:19 +08:00
Baohua Yang
d732713b06 Add dockerfile chapter 2014-10-10 17:30:53 +08:00
Baohua Yang
4e70438202 Rename the network chapter 2014-10-10 09:37:52 +08:00
Baohua Yang
5a642809d9 Minor changes on content 2014-10-10 09:37:15 +08:00
Baohua Yang
06b9651af9 Add more details to help understand repo and registry 2014-10-03 11:41:22 +08:00
Baohua Yang
8117a15804 Add comparison summary with vm 2014-10-03 11:34:57 +08:00
Baohua Yang
c48aa47432 minor change, add dockerpool link 2014-09-30 13:39:19 +08:00
Baohua Yang
d897954e8a Merge pull request #18 from patriot7/master
fix typo
2014-09-30 12:51:49 +08:00
Gao Xiang
1a6861476b fix typo 2014-09-29 17:36:46 -04:00
Baohua Yang
6fa5159bb9 Add new chapters to introduce the popular repositories 2014-09-27 16:06:08 +08:00
Baohua Yang
1faf0eeba6 rename the appendix chapter's directories 2014-09-27 13:26:40 +08:00
Baohua Yang
24191c2ebe Modify the import of bash file 2014-09-26 20:33:00 +08:00
Baohua Yang
e94bb1d13b Modify the usage of the bashrc file 2014-09-26 17:52:04 +08:00
Baohua Yang
7896cb5d7b Add more useful command 2014-09-26 17:46:05 +08:00
Baohua Yang
d4b8630bca Rewrite the introduction and minor fix 2014-09-26 17:45:51 +08:00
Baohua Yang
8857c11fa6 minor change to expression; unify the term and formatting 2014-09-26 16:05:13 +08:00
Baohua Yang
8add83dcc2 restruct the chapter to make it more understanding 2014-09-26 15:44:31 +08:00
Baohua Yang
6d890cab80 Note to start docker in ubuntu installation 2014-09-26 14:34:16 +08:00
Baohua Yang
0505622aeb Reformat the installation chapter 2014-09-26 14:14:13 +08:00
Baohua Yang
25c95840bf review the content 2014-09-26 14:08:26 +08:00
Baohua Yang
4098af51bc Update link to file directly 2014-09-25 22:09:04 +08:00
Baohua Yang
17ab6bcd7b Rewrite and add more details on attach and nsenter; add bashrc_docker file 2014-09-25 22:08:45 +08:00
Baohua Yang
73b5e3890e restruct and add brief introduction part 2014-09-25 17:23:05 +08:00
Baohua Yang
4901436e6b Use Docker instead of docker 2014-09-25 17:06:32 +08:00
Baohua Yang
37e650575f Merge pull request #17 from luashiping/master
add enter container
2014-09-25 16:55:53 +08:00
Baohua Yang
3d8dd3175f Add the repo configuration section 2014-09-25 16:46:37 +08:00
Baohua Yang
56fc8fd280 use -d to start container as daemon 2014-09-25 16:45:47 +08:00
Baohua Yang
d77c41dab7 Add contribution list 2014-09-25 16:45:03 +08:00
lushiping
5912b8fb00 add enter container 2014-09-25 16:09:50 +08:00
lushiping
929caa27e8 add enter container 2014-09-25 15:51:25 +08:00
lushiping
18507f9eaf Fix issue #1: change helo to hello 2014-09-25 15:42:21 +08:00
lushiping
ed6e476e94 Fix issue #1: change helo to hello 2014-09-25 15:31:18 +08:00
Baohua Yang
2422e4e19d Merge pull request #16 from hsgui/master
upstream without https:// could not work
2014-09-24 17:01:16 +08:00
hsgui
ec4e36bbf4 upstream without https:// could not work 2014-09-24 15:55:37 +08:00
Baohua Yang
ae67944ddf Merge pull request #15 from hsgui/master
Fix: change --volumne--from to --volumnes-from
2014-09-24 13:35:56 +08:00
Baohua Yang
cab41b6362 Merge pull request #14 from aisensiy/master
在 Image 章节发现的两个小错误
2014-09-24 13:34:52 +08:00
hsgui
10b432ab65 Fix: change --volumne--from to --volumnes-from 2014-09-24 13:10:32 +08:00
aisensiy
08ed01831a docker save is used to save image and docker export is used to export container 2014-09-24 12:27:00 +08:00
aisensiy
26620cb3d5 mysqld to httpd 2014-09-24 12:07:25 +08:00
Baohua Yang
a9825f93e9 Update local repo usage, add a batch script to upload local images 2014-09-24 11:03:46 +08:00
Baohua Yang
86f8095149 Add more examples on using local repo 2014-09-23 16:40:54 +08:00
Baohua Yang
ff245474dc Add the backup repo server 2014-09-23 15:07:38 +08:00
Baohua Yang
cef1322014 Fix issue#12, cmd should be run with root privilege 2014-09-23 13:45:50 +08:00
Baohua Yang
b5d4a05d4b Add more details to use the local repo 2014-09-23 13:14:45 +08:00
Baohua Yang
876ea4c9d6 Add more accurate link 2014-09-22 16:43:23 +08:00
Baohua Yang
9fd703bc18 Add change log 2014-09-22 16:43:05 +08:00
Baohua Yang
2a60b4ce7e Remove the local repo case, add its content into the image and repository sections 2014-09-22 16:40:18 +08:00
Baohua Yang
71bcec05b7 Rewrite the local repo deployment case 2014-09-22 15:52:53 +08:00
Baohua Yang
ed2750776a Rewrite the other security feature part and security summary part 2014-09-22 11:19:52 +08:00
Baohua Yang
07edb7e3c1 Update the term to better meaning 2014-09-22 10:56:15 +08:00
Baohua Yang
3e9f1343f0 Merge branch 'cxjava-master' 2014-09-22 10:05:24 +08:00
Baohua Yang
71f0f50f27 Merge branch 'master' of https://github.com/cxjava/docker_practice into cxjava-master
Conflicts:
	security/control_group.md
	security/daemon_sec.md
	security/kernel_capability.md
	security/kernel_ns.md
2014-09-22 10:04:22 +08:00
Baohua Yang
909dfb8e12 Merge branch 'master' of github.com:yeasy/docker_practice 2014-09-22 09:49:10 +08:00
Baohua Yang
554224406b Change section title 2014-09-22 09:47:08 +08:00
Baohua Yang
ca451d866f Merge pull request #10 from bill2004158/master
fix link url
2014-09-22 09:45:33 +08:00
bill2004158
eb203c80d5 fix link url 2014-09-22 00:43:50 +08:00
Baohua Yang
59abd4883d rewrite the kernel capability part 2014-09-21 22:07:06 +08:00
Baohua Yang
8c59d79c5b rewrite the daemon part 2014-09-21 21:44:55 +08:00
Baohua Yang
467edbe130 rewrite the control group part 2014-09-21 21:33:51 +08:00
Baohua Yang
64ed80de0d rewrite the kernel security part 2014-09-21 21:33:30 +08:00
Baohua Yang
ece126aa1b rewrite the introduction of docker security 2014-09-21 21:33:06 +08:00
Baohua Yang
337065434d Add cover pages 2014-09-21 21:32:42 +08:00
Baohua Yang
c5b81e3330 Add the book.json file 2014-09-21 21:32:13 +08:00
Charles
2a21c2f595 Merge branch 'master' of github.com:cxjava/docker_practice 2014-09-21 20:51:13 +08:00
Charles
96b199aae2 Fixed the wrong Chinese character 2 2014-09-21 20:50:55 +08:00
Charles
5d00f5476b Fixed the wrong Chinese character 2014-09-21 20:48:49 +08:00
Charles
39ef881ace Fixed the wrong Chinese character 2014-09-21 20:27:40 +08:00
Baohua Yang
672316dfb5 Change read link address to the front page 2014-09-21 18:19:09 +08:00
Baohua Yang
f0eb7ac601 restruct and publish new version 0.2.1 2014-09-21 13:58:23 +08:00
Baohua Yang
7f31be0ed9 rename 2014-09-21 13:51:26 +08:00
Baohua Yang
49c4143e27 rename 2014-09-21 13:50:34 +08:00
Baohua Yang
c184f014ae Merge pull request #8 from windwiny/patch-1
Update tomcat.md
2014-09-21 13:46:52 +08:00
Baohua Yang
7b0e52f309 Write the underly/network chapter 2014-09-21 13:40:10 +08:00
windwiny
aa3ff4dc6a Update tomcat.md 2014-09-21 11:47:56 +08:00
Baohua Yang
d544c2949f Update the instruction with latest official document 2014-09-20 21:50:27 +08:00
Baohua Yang
b94178ee16 Merge pull request #7 from kmiku7/master
Fix install commands on CentOS
2014-09-20 21:44:18 +08:00
kmiku7
4567e7e6f7 Fix install commands on CentOS 2014-09-21 02:15:13 +08:00
Baohua Yang
f4dc2303f6 Fix issue#6: clarify the differences between image:save,load and container:export,import 2014-09-19 21:51:21 +08:00
Baohua Yang
8dffa923bc minor revision; update link 2014-09-19 11:23:25 +08:00
Baohua Yang
2b40097e66 Add guide on how to participate the project 2014-09-18 22:13:12 +08:00
Baohua Yang
0e65e07e3d Add the section of network config file 2014-09-18 17:38:42 +08:00
Baohua Yang
23d4e36c64 rewrite the advanced network chapter 2014-09-18 17:38:20 +08:00
Baohua Yang
424e07993e Change to more accurate expression 2014-09-18 15:55:24 +08:00
Baohua Yang
a3d8341e27 rewrite the fast_config and dns part of the advanced network chapter 2014-09-18 14:09:51 +08:00
Baohua Yang
0d48072d5c rewrite the introduction of advanced network chapter; redraw the figure 2014-09-18 13:07:31 +08:00
Baohua Yang
b1e6415b8f Finish the basic content for the underly chapter 2014-09-18 10:45:17 +08:00
Baohua Yang
d83e318b8c reduce the technical part 2014-09-18 10:34:52 +08:00
Baohua Yang
1065a728ce minor fix 2014-09-17 23:25:32 +08:00
Baohua Yang
1ac18858b5 restruct and add more content to introduce cgroups, ufs and container format 2014-09-17 20:53:14 +08:00
Baohua Yang
99f9a77b3c fix link info 2014-09-17 20:30:06 +08:00
Baohua Yang
b20eb11659 Add more detailed comments 2014-09-17 20:26:35 +08:00
Baohua Yang
6c1eeadd14 write the repository chapter content 2014-09-17 20:18:51 +08:00
Baohua Yang
faacf4c31d fix formatting and content 2014-09-17 19:42:22 +08:00
Baohua Yang
beb5a07855 change terminology 2014-09-17 19:36:51 +08:00
Baohua Yang
edbc260ba9 Merge branch 'master' of github.com:yeasy/docker_practice
Conflicts:
	practice/supervisor.md
2014-09-17 19:33:05 +08:00
Baohua Yang
7fda9225a1 fix code formatting and rewrite part content 2014-09-17 19:23:52 +08:00
Baohua Yang
2b90922922 Merge pull request #3 from dreampuf/patch-1
Fix a code block issue
2014-09-17 19:23:20 +08:00
Baohua Yang
cdb5a2b4c7 Merge pull request #2 from liangry/master
Fix permission denied error in ubuntu installation
2014-09-17 19:20:54 +08:00
Baohua Yang
22afe36b0f fix the terminologies, add more content 2014-09-17 16:31:25 +08:00
Dreampuf
2403f6e73d Fix codeblock issue 2014-09-17 16:22:47 +08:00
Dreampuf
4ad69eb796 Fix a codeblock issue 2014-09-17 16:21:41 +08:00
Baohua Yang
7f5c1acf09 refine the expression 2014-09-17 16:14:22 +08:00
Baohua Yang
a228773062 Add the original manual file by waitfish 2014-09-17 15:59:23 +08:00
Dreampuf
910786014e Fix a code block issue 2014-09-17 15:14:33 +08:00
Baohua Yang
4abab290ac Add .idea and _book directories into gitignore file 2014-09-17 14:59:13 +08:00
Baohua Yang
389c15d748 rename images directory to _images 2014-09-17 14:52:55 +08:00
Baohua Yang
c50e2aaf60 change the struct of image chapter, add export/import and join the docker hub related operations together 2014-09-17 14:33:06 +08:00
Baohua Yang
615bb9f517 Add more content 2014-09-17 14:16:45 +08:00
Ruoyu
c057d68cec Fix permission denied error in ubuntu installation 2014-09-17 14:16:08 +08:00
Baohua Yang
3ec888c77a Based on pull request#1, change the figure name suffix 2014-09-17 14:14:58 +08:00
Baohua Yang
99b0f8fe72 Fix terms 2014-09-17 13:45:13 +08:00
Baohua Yang
34d63d30f3 Rewrite the data_management chapter 2014-09-16 13:31:53 +08:00
Baohua Yang
dbb12986da Add more information on the discuss group 2014-09-16 10:26:19 +08:00
Baohua Yang
64a0f39dff rewrite the container, network chapters 2014-09-15 22:30:23 +08:00
Baohua Yang
da60ad7b47 Add image/list.md and dockerfile chapter 2014-09-15 21:51:21 +08:00
Baohua Yang
2c939cf20f Fix word in image chapter 2014-09-15 21:28:09 +08:00
Baohua Yang
e91a4955e9 Add the container chapter 2014-09-15 21:25:36 +08:00
Baohua Yang
fc7aa02f50 Finish the basic version of the basic_concept chapter 2014-09-15 17:36:31 +08:00
Baohua Yang
813c3bdab1 Add two chapters:container and repository 2014-09-15 17:11:22 +08:00
Baohua Yang
80eda65481 Restruct and start rewring. 2014-09-15 17:08:06 +08:00
Baohua Yang
f14fddbba8 minor fix 2014-09-14 14:04:30 +08:00
Baohua Yang
a9dddd5bc1 Add resources chapter 2014-09-14 14:01:26 +08:00
Baohua Yang
68e02605f6 Add more commands in creating an image 2014-09-14 13:57:19 +08:00
Baohua Yang
743a09086a Add cover figure 2014-09-12 20:34:15 +08:00
Baohua Yang
e6986e387e minor change 2014-09-12 16:18:48 +08:00
Baohua Yang
71adb73dbb Rewrite the content 2014-09-12 16:18:24 +08:00
Baohua Yang
e6883a4ef2 Refine and fix 2014-09-12 16:17:56 +08:00
Baohua Yang
7fc1ca0733 split the installation to two main distributions 2014-09-12 15:37:21 +08:00
Baohua Yang
79934ad3e1 Add figure for the command logic 2014-09-12 15:36:41 +08:00
Baohua Yang
0258da9046 fix wrong link name 2014-09-12 11:01:57 +08:00
Baohua Yang
e0405a38d6 rename the first chapter 2014-09-12 10:52:17 +08:00
Baohua Yang
afa47edf45 Add docker command page 2014-09-12 10:51:47 +08:00
Baohua Yang
f5ab41b2fa Add new chapters: the docker command 2014-09-11 22:52:57 +08:00
Baohua Yang
1d101330fd express refine 2014-09-11 22:52:28 +08:00
Baohua Yang
1f5fb2d521 Rewrite part of the architecture introduction 2014-09-11 17:07:49 +08:00
Baohua Yang
235a80aad8 Write paragraphs to explain why we need docker; minor grammar fix. 2014-09-11 16:56:34 +08:00
195 changed files with 6338 additions and 903 deletions

7
.gitignore vendored
View File

@@ -1,3 +1,8 @@
# Created by .gitignore support plugin (hsz.mobi)
*.~
*.tmp
*.tmp
.idea/
_book/
*.swp
*.edx
.DS_Store

View File

@@ -1,19 +1,85 @@
Docker -- 从入门到实践
Docker —— 从入门到实践
===============
v0.1
v0.6.0
[Docker] (docker.com)是个伟大的项目
[Docker](http://www.docker.com) 是个很有意思的开源项目,它彻底释放了虚拟化的威力,极大降低了云计算资源供应的成本,同时让应用的部署、测试和分发都变得前所未有的高效和轻松
本书最初源于[WaitFish](mailto:dwj_wz@163.com)
创作的<Docker学习手册v1.0> pdf内容后来[yeasy](github.com/yeasy)
根据最新的官方文档对内容进行了修订,并与作者[WaitFish]
(mailto:dwj_wz@163
.com)协商,将内容开源,采用互联网合作的方式进行创作和维护。
本书既适用于具备基础 Linux 知识的 Docker 初学者,也希望可供理解原理和实现的高级用户参考。同时,书中给出的实践案例,可供在进行实际部署时借鉴。前六章为基础内容,供用户理解 Docker 的基本概念和操作7 ~ 9 章介绍一些高级操作;第 10 章给出典型的应用场景和实践案例11 ~ 13 章介绍关于 Docker 实现的相关细节技术。后续章节则分别介绍一些相关的热门开源项目。
在线阅读:[https://www.gitbook.io/book/yeasy/docker_practice](https://www.gitbook.io/book/yeasy/docker_practice)
在线阅读:[GitBook](https://www.gitbook.io/book/yeasy/docker_practice) 或 [DockerPool](http://dockerpool.com/static/books/docker_practice/index.html)
维护本书的Github项目: [https://github.com/yeasy/docker_practice](https://github
.com/yeasy/docker_practice)
欢迎关注 DockerPool 社区微博 [@dockerpool](http://weibo.com/u/5345404432),或加入 Docker 技术交流 QQ 群或微信组,分享 Docker 资源,交流 Docker 技术。
欢迎大家提交pull request。
* QQ 群I 已满341410255
* QQ 群II 已满419042067
* QQ 群III可加210028779
![Docker 技术入门与实战](docker_primer.png)
《[Docker 技术入门与实战](http://item.jd.com/11598400.html)》一书已经正式出版,包含大量第一手实战案例和更为深入的技术剖析,欢迎大家阅读使用并帮忙反馈建议。
* [China-Pub](http://product.china-pub.com/3770833)
* [京东图书](http://item.jd.com/11598400.html)
* [当当图书](http://product.dangdang.com/23620853.html)
* [亚马逊图书](http://www.amazon.cn/%E5%9B%BE%E4%B9%A6/dp/B00R5MYI7C/ref=lh_ni_t?ie=UTF8&psc=1&smid=A1AJ19PSB66TGU)
## 主要版本历史
* 0.6.0: 2015-12-24
* 补充 Machine 项目
* 修正若干 bug
* 0.5: 2015-06-29
* 添加 Compose 项目
* 添加 Machine 项目
* 添加 Swarm 项目
* 完善 Kubernetes 项目内容
* 添加 Mesos 项目内容
* 0.4: 2015-05-08
* 添加 Etcd 项目
* 添加 Fig 项目
* 添加 CoreOS 项目
* 添加 Kubernetes 项目
* 0.3: 2014-11-25
* 完成仓库章节;
* 重写安全章节;
* 修正底层实现章节的架构、名字空间、控制组、文件系统、容器格式等内容;
* 添加对常见仓库和镜像的介绍;
* 添加 Dockerfile 的介绍;
* 重新校订中英文混排格式。
* 修订文字表达。
* 发布繁体版本分支zh-Hant。
* 0.2: 2014-09-18
* 对照官方文档重写介绍、基本概念、安装、镜像、容器、仓库、数据管理、网络等章节;
* 添加底层实现章节;
* 添加命令查询和资源链接章节;
* 其它修正。
* 0.1: 2014-09-05
* 添加基本内容;
* 修正错别字和表达不通顺的地方。
Docker 自身仍在快速发展中,生态环境也在蓬勃成长。源码开源托管在 Github 上,欢迎参与维护:[https://github.com/yeasy/docker_practice](https://github.com/yeasy/docker_practice)。贡献者 [名单](https://github.com/yeasy/docker_practice/graphs/contributors)。
## 参加步骤
* 在 GitHub 上 `fork` 到自己的仓库,如 `docker_user/docker_practice`,然后 `clone` 到本地,并设置用户信息。
```
$ git clone git@github.com:docker_user/docker_practice.git
$ cd docker_practice
$ git config user.name "yourname"
$ git config user.email "your email"
```
* 修改代码后提交,并推送到自己的仓库。
```
$ #do some change on the content
$ git commit -am "Fix issue #1: change helo to hello"
$ git push
```
* 在 GitHub 网站上提交 pull request。
* 定期使用项目仓库内容更新自己仓库内容。
```
$ git remote add upstream https://github.com/yeasy/docker_practice
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
$ git push -f origin master
```

View File

@@ -1,53 +1,128 @@
#目录
* [为什么要使用docker](why_use_docker/README.md)
- [快速交付应用程序](why_use_docker/fast_deployment.md)
- [更容易部署和扩展](why_use_docker/easy_deployment.md)
- [效率更高](why_use_docker/high_efficiency.md)
- [快速部署也意味着更简单的管理](why_use_docker/easy_management.md)
* [Docker的体系结构](arch/README.md)
- [内部组件](arch/internal.md)
- [image的工作原理](arch/image.md)
- [仓库](arch/repo.md)
- [容器](arch/container.md)
- [底层技术](arch/underly.md)
# Summary
* [前言](README.md)
* [Docker 简介](introduction/README.md)
* [什么是 Docker](introduction/what.md)
* [为什么要用 Docker](introduction/why.md)
* [基本概念](basic_concept/README.md)
* [镜像](basic_concept/image.md)
* [容器](basic_concept/container.md)
* [仓库](basic_concept/repository.md)
* [安装](install/README.md)
- [Ubuntu 14.04](install/ubuntu144.md)
- [Ubuntu 12.04](install/ubuntu124.md)
- [CentOS](install/centos.md)
* [image介绍](image/README.md)
- [获取mage](image/get.md)
- [查找image](image/search.md)
- [下载image](image/download.md)
- [创建自己的image](image/create.md)
- [上传image](image/push.md)
- [移除本地image](image/rmi.md)
* [网络介绍](network/README.md)
- [端口映射](network/port_mapping.md)
- [docker中的容器互联-linking系统](network/linking.md)
* [高级网络配置](advanced_network/README.md)
- [快速配置](advanced_network/fast_config.md)
- [配置DNS](advanced_network/dns.md)
- [容器之间的通信](advanced_network/communication.md)
- [映射一个容器端口到宿主主机](advanced_network/port_mapping.md)
- [定制docker0](advanced_network/docker0.md)
- [创建自己的桥接](advanced_network/bridge.md)
- [Docker 如何连接到容器](advanced_network/how_connect.md)
- [工具和示例](advanced_network/example.md)
- [创建一个点到点连接](advanced_network/ptp.md)
* [Ubuntu](install/ubuntu.md)
* [CentOS](install/centos.md)
* [镜像](image/README.md)
* [获取镜像](image/pull.md)
* [列出](image/list.md)
* [创建](image/create.md)
* [存出和载入](image/save_load.md)
* [移除](image/rmi.md)
* [实现原理](image/internal.md)
* [容器](container/README.md)
* [启动](container/run.md)
* [守护态运行](container/daemon.md)
* [终止](container/stop.md)
* [进入容器](container/enter.md)
* [导出和导入](container/import_export.md)
* [删除](container/rm.md)
* [仓库](repository/README.md)
* [Docker Hub](repository/dockerhub.md)
* [私有仓库](repository/local_repo.md)
* [配置文件](repository/config.md)
* [数据管理](data_management/README.md)
- [数据卷](data_management/volume.md)
- [数据卷容器](data_management/container.md)
- [备份、恢复、移数据卷](data_management/management.md)
* [容器安全](container_security/README.md)
- [内核名字空间](container_security/kernel_ns.md)
- [控制组](container_security/control_group.md)
- [守护进程安全](container_security/daemon_sec.md)
- [内核权限](container_security/kernel_capability.md)
- [其他内核安全特性](container_security/other_feature.md)
- [结论](container_security/summary.md)
* [实战案例](practice/README.md)
- [部署本地仓库](practice/local_repo.md)
- [在Docker中使用 Supervisor来管理进程](practice/supervisor.md)
* [创建tomcat/weblogic集群](practice/tomcat.md)
* [多台物理主机之间的容器互联](practice/container_connect.md)
* [中小企业docker环境搭建](practice/environment.md)
* [数据卷](data_management/volume.md)
* [数据卷容器](data_management/container.md)
* [备份、恢复、移数据卷](data_management/management.md)
* [使用网络](network/README.md)
* [外部访问容器](network/port_mapping.md)
* [容器互联](network/linking.md)
* [高级网络配置](advanced_network/README.md)
* [快速配置指南](advanced_network/quick_guide.md)
* [配置 DNS](advanced_network/dns.md)
* [容器访问控制](advanced_network/access_control.md)
* [端口映射实现](advanced_network/port_mapping.md)
* [配置 docker0 网桥](advanced_network/docker0.md)
* [自定义网桥](advanced_network/bridge.md)
* [工具和示例](advanced_network/example.md)
* [编辑网络配置文件](advanced_network/config_file.md)
* [实例:创建一个点到点连接](advanced_network/ptp.md)
* [实战案例](cases/README.md)
* [使用 Supervisor 来管理进程](cases/supervisor.md)
* [创建 tomcat/weblogic 集群](cases/tomcat.md)
* [多台物理主机之间的容器互联](cases/container_connect.md)
* [标准化开发测试和生产环境](cases/environment.md)
* [安全](security/README.md)
* [内核名字空间](security/kernel_ns.md)
* [控制组](security/control_group.md)
* [服务端防护](security/daemon_sec.md)
* [内核能力机制](security/kernel_capability.md)
* [其它安全特性](security/other_feature.md)
* [总结](security/summary.md)
* [Dockerfile](dockerfile/README.md)
* [基本结构](dockerfile/basic_structure.md)
* [指令](dockerfile/instructions.md)
* [创建镜像](dockerfile/build_image.md)
* [底层实现](underly/README.md)
* [基本架构](underly/arch.md)
* [名字空间](underly/namespace.md)
* [控制组](underly/cgroups.md)
* [联合文件系统](underly/ufs.md)
* [容器格式](underly/container_format.md)
* [网络](underly/network.md)
* [Docker Compose 项目](compose/README.md)
* [简介](compose/intro.md)
* [安装](compose/install.md)
* [使用](compose/usage.md)
* [命令说明](compose/commands.md)
* [YAML 模板文件](compose/yaml_file.md)
* [Docker Machine 项目](machine/README.md)
* [简介](machine/intro.md)
* [安装](machine/install.md)
* [使用](machine/usage.md)
* [Docker Swarm 项目](swarm/README.md)
* [简介](swarm/intro.md)
* [安装](swarm/install.md)
* [使用](swarm/usage.md)
* [调度器](swarm/scheduling.md)
* [过滤器](swarm/filter.md)
* [Etcd 项目](etcd/README.md)
* [简介](etcd/intro.md)
* [安装](etcd/install.md)
* [使用 etcdctl](etcd/etcdctl.md)
* [Fig 项目](fig/README.md)
* [简介](fig/intro.md)
* [安装](fig/install.md)
* [命令参考](fig/cli_ref.md)
* [fig.yml参考](fig/yml_ref.md)
* [环境变量参考](fig/env_ref.md)
* [实战 Django](fig/django.md)
* [实战 Rails](fig/rails.md)
* [实战 wordpress](fig/wordpress.md)
* [CoreOS 项目](coreos/README.md)
* [简介](coreos/intro.md)
* [工具](coreos/intro_tools.md)
* [快速搭建CoreOS集群](coreos/quickstart.md)
* [Kubernetes 项目](kubernetes/README.md)
* [简介](kubernetes/intro.md)
* [快速上手](kubernetes/quickstart.md)
* [基本概念](kubernetes/concepts.md)
* [kubectl 使用](kubernetes/kubectl.md)
* [架构设计](kubernetes/design.md)
* [Mesos 项目](mesos/README.md)
* [简介](mesos/intro.md)
* [安装与使用](mesos/installation.md)
* [原理与架构](mesos/architecture.md)
* [配置项解析](mesos/configuration.md)
* [常见框架](mesos/framework.md)
* [附录一:命令查询](appendix_command/README.md)
* [附录二:常见仓库介绍](appendix_repo/README.md)
* [Ubuntu](appendix_repo/ubuntu.md)
* [CentOS](appendix_repo/centos.md)
* [MySQL](appendix_repo/mysql.md)
* [MongoDB](appendix_repo/mongodb.md)
* [Redis](appendix_repo/redis.md)
* [Nginx](appendix_repo/nginx.md)
* [WordPress](appendix_repo/wordpress.md)
* [Node.js](appendix_repo/nodejs.md)
* [附录三:有用的资源](appendix_resources/README.md)

56
_images/cmd_logic.dot Normal file
View File

@@ -0,0 +1,56 @@
//dot -Tpng xx.dot -o xx.png
digraph G {
rankdir=TB;
fontname = "Microsoft YaHei";
fontsize = 14;
penwidth = 3;
compound=true;
rankdir=LR;
node [shape = record];
edge [fontname = "Arial", fontsize = 12, color="darkgreen" ];
image[label="Image",color=blue];
registry[label="Registry",color=blue];
tar[label="Tar files",color=blue];
subgraph cluster_container {
label = "Container";
style = "bold";
color = blue;
edge [fontname = "Arial", fontsize = 11, color="skyblue" ];
//node [style=filled];
run[label="Running",shape=circle, style=filled, fillcolor=green];
stop[label="Stopped",shape=circle, style=filled, fillcolor=red];
pause[label="Paused",shape=circle, style=filled, fillcolor=blue];
run->pause[label="pause"];
pause->run[label="unpause"];
run->run[label="restart"];
run->stop[label="kill"];
stop->run[label="start"];
}
run->image[label="commit",ltail=cluster_container];
image->run[label="start"];
image->tar[label="export|save"];
tar->image[label="import"];
image->registry[label="push"];
registry->image[label="pull"];
//heat[label="heat commands",color=blue];
//heatshell[label="heatclient.shell.HeatShell",color=blue];
//shell[label="{heatclient.v1.shell|+do_stack_create\l+do_stack_show\l+do_stack_update\l...\l+do_event_list\l...\l+do_resource_list\l...\l+do_resource_type_show\l...\l+do_template_show\l...\l}",color=blue];
//heatclient[label="heatclient.client.Client",color=blue];
//client[label="heatclient.v1.client.Client",color=blue];
//httpclient[label="heatclient.common.http.HTTPClient",color=blue];
//openstackservices[label="{OpenStack Services|+Nova\l+Neutron\l+Keystone\l...}",color=blue];
//{rank=same; image cluster_container}
//{rank=same; rpcproxy apimixin}
}

BIN
_images/cmd_logic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
_images/compose.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
_images/cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
_images/docker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

BIN
_images/docker_compose.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
_images/docker_machine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

BIN
_images/etcd_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

BIN
_images/kube-proxy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

374
_images/kubernetes_logo.svg Normal file
View File

@@ -0,0 +1,374 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
width="562.78589"
height="134.62993"
id="svg2"
xml:space="preserve"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs6" /><g
transform="matrix(1.25,0,0,-1.25,-169.2546,1414.8444)"
id="g10"><g
transform="matrix(0,0.18092,-0.18275,0,0,0)"
id="g12"><path
d="m 6196.6587,-1043.6173 -94.2902,-195.4939 -211.9113,-48.3046 -169.9617,135.2607 -0.025,216.9692 169.9297,135.2974 211.9254,-48.257 94.3336,-195.4718 z"
id="path14"
style="fill:none;stroke:#ffffff;stroke-width:118.52590179;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 190.7198,1121.0876 35.725,-17.0586 8.8274,-38.3391 -24.7181,-30.7489 -39.6505,0 -24.7249,30.7434 8.8192,38.3412 35.7219,17.0665 z"
id="path16"
style="fill:#336ee5;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0,0.18092,-0.18275,0,0,0)"
id="g18"><path
d="m 6196.6587,-1043.6173 -94.2888,-195.4939 -211.9141,-48.3046 -169.9603,135.2593 -0.025,216.9723 169.9297,135.2942 211.9237,-48.2572 94.3353,-195.4701 z"
id="path20"
style="fill:none;stroke:#336ee5;stroke-width:74.74790192;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><g
transform="scale(0.18275,0.18275)"
id="g22"><path
d="m 1013.0746,6022.3961 c 73.5242,16.6963 146.8298,-29.4129 163.7263,-102.9881 16.9013,-73.5693 -29.0033,-146.7459 -102.5258,-163.4409 -73.5273,-16.6903 -146.8343,29.4189 -163.7325,102.9867 -16.8967,73.5769 29.0047,146.7505 102.532,163.4423 z"
id="path24"
style="fill:none;stroke:#ffffff;stroke-width:30.78089905;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 188.4186,1104.8074 2.7468,-0.01 0.1749,-20.1918 -4.0657,-0.038 1.144,20.236 z"
id="path26"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="scale(0.17178,0.18275)"
id="g28"><path
d="m 1096.8024,6045.6095 15.9899,-0.036 1.0191,-110.4894 -23.6699,-0.2094 6.6609,110.7345 z"
id="path30"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 193.0309,1104.8074 -2.7474,-0.01 -0.1703,-20.1918 4.0654,-0.037 -1.1477,20.2354 z"
id="path32"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="scale(0.17178,0.18275)"
id="g34"><path
d="m 1123.6518,6045.6098 -15.993,-0.036 -0.991,-110.4894 23.6681,-0.2029 -6.6841,110.7283 z"
id="path36"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 192.8625,1112.4315 c 0,-1.3119 -0.9576,-2.3758 -2.1382,-2.3758 -1.1806,0 -2.1379,1.0639 -2.1379,2.3752 0,1.3119 0.9564,2.3754 2.1379,2.3763 1.1806,0 2.1382,-1.0636 2.1382,-2.3757"
id="path38"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.16447,2e-5,-2e-5,0.18275,0,0)"
id="g40"><path
d="m 1173.5053,6087.183 c -8e-4,-7.1804 -5.8238,-12.9997 -13.0019,-12.9988 -7.1785,8e-4 -12.998,5.8229 -12.9969,12.9971 0,7.1819 5.817,13.0011 13.0006,13.0031 7.1781,-6e-4 12.9994,-5.8229 12.9982,-13.0014 z"
id="path42"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 188.5873,1112.4629 c 5e-4,-0.1876 -0.009,-0.458 -0.003,-0.6389 0.0289,-0.7566 0.1945,-1.3368 0.294,-2.0344 0.1797,-1.4922 0.3311,-2.7289 0.2381,-3.8781 -0.0851,-0.5757 -0.4184,-0.8028 -0.6959,-1.0689 l 3.3721,-2.2315 -0.5069,9.8354 -2.6988,0.016 z"
id="path44"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0,-0.17178,0.18275,0,0,0)"
id="g46"><path
d="m -6476.0579,1031.9675 c 1.0925,0 2.6666,-0.048 3.7194,-0.014 4.4045,0.1568 7.7839,1.0641 11.8431,1.6087 8.6865,0.9819 15.8862,1.8102 22.5791,1.3028 3.3483,-0.4652 4.6701,-2.2896 6.2212,-3.8095 l 12.9884,18.4555 -57.257,-2.7751 -0.094,-14.7685 z"
id="path48"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 192.8625,1112.4629 c -0.001,-0.1876 0.008,-0.458 0.002,-0.6389 -0.0289,-0.7566 -0.1942,-1.3368 -0.2934,-2.0344 -0.1797,-1.4922 -0.3311,-2.7289 -0.2384,-3.8781 0.0847,-0.5757 0.4184,-0.8028 0.6959,-1.0689 l -3.3724,-2.2315 0.5074,9.8354 2.6989,0.016 z"
id="path50"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0,-0.17178,0.18275,0,0,0)"
id="g52"><path
d="m -6476.0579,1055.3604 c 1.0925,0 2.6666,0.046 3.7194,0.011 4.4045,-0.1534 7.7839,-1.0624 11.8431,-1.6022 8.6865,-0.9867 15.8862,-1.815 22.5791,-1.3076 3.3483,0.4669 4.6701,2.291 6.2212,3.8081 l 12.9884,-18.4541 -57.257,2.7765 -0.094,14.7685 z"
id="path54"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><g
transform="scale(0.18275,0.18275)"
id="g56"><path
d="m 1073.7275,5865.2637 -30.1062,-14.4303 -30.1,14.438 -7.4344,32.4422 20.8395,26.0065 33.4099,0 20.8321,-26.0175 -7.4409,-32.4374 z"
id="path58"
style="fill:none;stroke:#ffffff;stroke-width:30.34600067;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 166.9153,1092.2468 1.7178,2.1436 15.8952,-12.4532 -2.5049,-3.2023 -15.1081,13.5119 z"
id="path60"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.1071,0.1343,-0.14288,0.11394,0,0)"
id="g62"><path
d="m 5577.0313,3012.37 15.9908,-0.036 1.0134,-110.4917 -23.6665,-0.2083 6.6623,110.7357 z"
id="path64"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 169.7905,1095.853 -1.7074,-2.1523 15.6805,-12.723 2.5636,3.1561 -16.5367,11.7192 z"
id="path66"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.1071,0.1343,-0.14288,0.11394,0,0)"
id="g68"><path
d="m 5603.8799,3012.3729 -15.9928,-0.039 -0.9944,-110.4931 23.6693,-0.2001 -6.6821,110.7321 z"
id="path70"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 163.7252,1100.4746 c 1.0258,-0.8183 1.2608,-2.2297 0.5247,-3.1529 -0.7368,-0.9233 -2.1651,-1.0089 -3.191,-0.1908 -1.0256,0.8181 -1.2606,2.2292 -0.5238,3.1524 0.7358,0.9235 2.1642,1.0086 3.1901,0.1913"
id="path72"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.10253,0.1286,-0.14289,0.11392,0,0)"
id="g74"><path
d="m 5852.363,3053.3992 c 0,-7.181 -5.8216,-13.0011 -13.0009,-13.0005 -7.1815,0 -13.0025,5.8227 -13.0013,13.0025 0,7.1796 5.8198,12.9977 13.0013,12.9949 7.1799,0 12.998,-5.8198 13.0009,-12.9969 z"
id="path76"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 161.0351,1097.1516 c 0.1474,-0.1171 0.3518,-0.2931 0.4986,-0.4005 0.6089,-0.4496 1.1656,-0.6818 1.7734,-1.0387 1.2781,-0.7894 2.3397,-1.4428 3.1807,-2.232 0.3969,-0.4249 0.3662,-0.8268 0.4008,-1.2104 l 3.8472,1.2453 -8.0047,5.7356 -1.696,-2.0993 z"
id="path78"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.1343,-0.1071,0.11394,0.14288,0,0)"
id="g80"><path
d="m -3249.2299,5243.3232 c 1.0919,-9e-4 2.6612,-0.054 3.7205,-0.014 4.403,0.1539 7.7794,1.0602 11.8417,1.6056 8.6817,0.9844 15.8837,1.8121 22.5768,1.3042 3.3486,-0.4641 4.6681,-2.2882 6.2175,-3.8109 l 12.9912,18.4518 -57.2536,-2.7726 -0.094,-14.7639 z"
id="path82"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 163.6999,1100.4936 c 0.1472,-0.1176 0.3643,-0.278 0.5012,-0.3965 0.574,-0.4944 0.9247,-0.9851 1.4077,-1.4979 1.0548,-1.0709 1.9275,-1.9601 2.8842,-2.6039 0.5026,-0.2928 0.8876,-0.1737 1.2691,-0.1221 l -0.3586,-4.0275 -7.3732,6.5273 1.6696,2.1206 z"
id="path84"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.1343,-0.1071,0.11394,0.14288,0,0)"
id="g86"><path
d="m -3249.2341,5266.7113 c 1.0978,-3e-4 2.6671,0.053 3.7204,0.013 4.4068,-0.1565 7.7837,-1.0596 11.8432,-1.6053 8.6876,-0.983 15.8876,-1.8099 22.5782,-1.2999 3.3503,0.462 4.6704,2.2847 6.2195,3.8072 l 12.9884,-18.4521 -57.2517,2.768 -0.098,14.7688 z"
id="path88"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 163.3717,1067.5885 -0.6052,2.6796 19.6464,4.6636 0.9419,-3.9555 -19.9831,-3.3877 z"
id="path90"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.03823,-0.16747,0.17816,0.04067,0,0)"
id="g92"><path
d="m -5847.3595,2171.5736 -15.992,0.034 -1.017,110.4899 23.669,0.2087 -6.66,-110.7329 z"
id="path94"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 162.3444,1072.0845 0.6182,-2.6767 19.7238,4.3271 -0.8685,3.9719 -19.4735,-5.6223 z"
id="path96"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.03823,-0.16747,0.17816,0.04067,0,0)"
id="g98"><path
d="m -5874.2073,2171.5679 15.9931,0.04 0.9924,110.4916 -23.6673,0.203 6.6818,-110.7349 z"
id="path100"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 154.9497,1070.2236 c 1.2787,0.2928 2.529,-0.4039 2.7921,-1.5551 0.2625,-1.1509 -0.561,-2.3213 -1.8405,-2.6127 -1.2785,-0.2928 -2.5285,0.4039 -2.7919,1.5551 -0.2625,1.1509 0.5613,2.3207 1.8403,2.6127"
id="path102"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.03662,-0.16034,0.17816,0.04069,0,0)"
id="g104"><path
d="m -6133.9467,2130.5761 c 0,7.1782 5.8161,12.9985 12.9991,12.9988 7.1756,-3e-4 12.9985,-5.8192 12.9951,-13.0005 0.01,-7.1753 -5.8189,-12.9966 -12.9988,-12.9988 -7.1773,5e-4 -12.9963,5.8218 -12.9954,13.0005 z"
id="path106"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 155.8706,1066.049 c 0.1829,0.042 0.4488,0.093 0.6234,0.14 0.7316,0.1962 1.2606,0.4867 1.9182,0.7387 1.4148,0.508 2.5869,0.9301 3.7281,1.0951 0.58,0.046 0.8745,-0.2282 1.1968,-0.4405 l 1.4247,3.7842 -9.4759,-2.6816 0.5847,-2.6359 z"
id="path108"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.16747,0.03823,-0.04067,0.17816,0,0)"
id="g110"><path
d="m 2265.6285,5497.4356 c 1.0922,0 2.6666,-0.045 3.7177,-0.01 4.4093,0.1534 7.7862,1.0596 11.8448,1.603 8.6851,0.9845 15.8865,1.8117 22.5771,1.3023 3.3483,-0.4592 4.6676,-2.2825 6.2201,-3.8072 l 12.9895,18.4535 -57.2534,-2.7672 -0.096,-14.7744 z"
id="path112"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 154.9191,1070.2165 c 0.1834,0.042 0.4447,0.1106 0.6224,0.1451 0.7447,0.1404 1.3471,0.1078 2.0489,0.1661 1.4947,0.1571 2.7338,0.2849 3.8339,0.6313 0.5428,0.2106 0.6894,0.5859 0.8867,0.9165 l 2.9262,-2.791 -9.701,-1.696 -0.6171,2.628 z"
id="path114"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.16747,0.03823,-0.04067,0.17816,0,0)"
id="g116"><path
d="m 2265.6266,5520.8273 c 1.0955,0 2.6674,0.048 3.7193,0.017 4.4096,-0.1585 7.7859,-1.0659 11.8448,-1.6093 8.6865,-0.9822 15.8843,-1.809 22.5766,-1.3005 3.3536,0.4626 4.6684,2.287 6.2195,3.8092 l 12.9917,-18.4527 -57.2533,2.7683 -0.099,14.7682 z"
id="path118"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 180.4031,1049.4196 -2.473,1.1973 8.6032,18.2685 3.6802,-1.73 -9.8104,-17.7358 z"
id="path120"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.15477,-0.07453,0.07929,0.16465,0,0)"
id="g122"><path
d="m -1704.3131,5602.1797 -15.9959,0.035 -1.0171,110.4913 23.6718,0.2081 -6.6588,-110.7343 z"
id="path124"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 176.2469,1051.4203 2.4784,-1.1858 8.9141,18.1179 -3.6474,1.7978 -7.7451,-18.7299 z"
id="path126"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.15477,-0.07453,0.07929,0.16465,0,0)"
id="g128"><path
d="m -1731.1657,5602.1774 15.9936,0.038 0.9918,110.4882 -23.669,0.2044 6.6836,-110.7309 z"
id="path130"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 173.0911,1044.4779 c 0.5695,1.1824 1.8927,1.7255 2.9568,1.2132 1.0642,-0.5122 1.4653,-1.8858 0.8964,-3.0676 -0.5687,-1.1826 -1.8933,-1.7252 -2.9569,-1.2132 -1.0644,0.5122 -1.4655,1.8856 -0.8963,3.0676"
id="path132"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.14819,-0.07134,0.07926,0.16466,0,0)"
id="g134"><path
d="m -1806.2371,5560.6799 c 3e-4,7.1804 5.821,12.9988 13.0023,13.0011 7.1781,0 12.9974,-5.8221 12.9957,-12.9997 0.01,-7.1801 -5.821,-12.9991 -12.9974,-12.9994 -7.1822,-5e-4 -13.0014,5.819 -13.0006,12.998 z"
id="path136"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 176.9292,1042.5954 c 0.0817,0.1695 0.207,0.4085 0.2792,0.5749 0.3033,0.6934 0.4057,1.2883 0.6183,1.9596 0.4853,1.4227 0.8858,2.6025 1.468,3.5974 0.3266,0.4819 0.7249,0.542 1.0908,0.6614 l -2.0698,3.4733 -3.8107,-9.0808 2.4242,-1.1858 z"
id="path138"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.07453,0.15477,-0.16465,0.07929,0,0)"
id="g140"><path
d="m 5915.209,1602.9547 c 1.0953,0 2.6649,-0.05 3.7202,-0.012 4.4056,0.1519 7.7811,1.0601 11.8409,1.605 8.6862,0.9844 15.8865,1.8127 22.5763,1.3028 3.3508,-0.4666 4.6717,-2.2873 6.222,-3.8084 l 12.9909,18.4516 -57.2547,-2.7709 -0.096,-14.7685 z"
id="path142"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 173.0784,1044.4501 c 0.0813,0.169 0.1902,0.4165 0.2744,0.5766 0.354,0.6698 0.7554,1.12 1.1471,1.7059 0.8099,1.266 1.482,2.3145 1.8975,3.3905 0.1735,0.5553 -0.0286,0.904 -0.1644,1.2646 l 4.0071,0.5473 -4.7237,-8.6411 -2.438,1.1562 z"
id="path144"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.07453,0.15477,-0.16465,0.07929,0,0)"
id="g146"><path
d="m 5915.2107,1626.3439 c 1.0917,0 2.6638,0.052 3.7171,0.016 4.4073,-0.1553 7.7822,-1.0655 11.8432,-1.6064 8.6876,-0.9845 15.8853,-1.8102 22.5771,-1.3051 3.3499,0.4646 4.6689,2.2873 6.22,3.8141 l 12.9887,-18.4575 -57.2528,2.7737 -0.093,14.7653 z"
id="path148"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 205.2142,1051.4548 -2.4778,-1.1863 -8.9186,18.1171 3.6467,1.798 7.7497,-18.7288 z"
id="path150"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.15477,0.07454,-0.0793,0.16465,0,0)"
id="g152"><path
d="m 3732.232,4696.5288 -15.992,0.035 -1.0145,110.4942 23.669,0.2069 -6.6625,-110.7357 z"
id="path154"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 201.0589,1049.4533 2.4729,1.1988 -8.6082,18.2661 -3.6797,-1.7314 9.815,-17.7335 z"
id="path156"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.15477,0.07454,-0.0793,0.16465,0,0)"
id="g158"><path
d="m 3705.3822,4696.5274 15.9982,0.038 0.9873,110.4936 -23.6687,0.201 6.6832,-110.7329 z"
id="path160"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 204.5188,1042.6575 c -0.5697,1.1821 -0.1686,2.5563 0.8952,3.0685 1.0636,0.5122 2.3879,-0.03 2.9574,-1.2124 0.5689,-1.182 0.1684,-2.5554 -0.8952,-3.0682 -1.0644,-0.5125 -2.3876,0.031 -2.9574,1.2121"
id="path162"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.14817,0.07138,-0.07932,0.16464,0,0)"
id="g164"><path
d="m 3871.7606,4654.3567 c -9e-4,7.1818 5.8221,13.0025 13.0017,13.0022 7.1767,0 12.9999,-5.8209 12.9991,-13.002 0,-7.1784 -5.8212,-12.9977 -13,-12.9996 -7.183,0 -12.9977,5.8215 -13.0008,12.9994 z"
id="path166"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 208.3836,1044.4844 c -0.0811,0.1698 -0.1896,0.4167 -0.2747,0.5775 -0.354,0.6698 -0.7554,1.1199 -1.1472,1.7056 -0.8095,1.2665 -1.4819,2.3142 -1.8978,3.3908 -0.1732,0.5553 0.029,0.9037 0.1636,1.2639 l -4.0059,0.5477 4.7233,-8.6411 2.4387,1.1556 z"
id="path168"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.07454,-0.15477,0.16465,0.0793,0,0)"
id="g170"><path
d="m -4951.7391,3507.378 c -1.097,5e-4 -2.6659,0.055 -3.7224,0.017 -4.4059,-0.1556 -7.7822,-1.065 -11.844,-1.6073 -8.6868,-0.9827 -15.8817,-1.8093 -22.5771,-1.3039 -3.35,0.4646 -4.665,2.2876 -6.2153,3.8089 l -12.992,-18.4507 57.2536,2.7686 0.097,14.7677 z"
id="path172"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 204.5333,1042.6297 c -0.0825,0.1693 -0.2072,0.4091 -0.2801,0.5746 -0.3024,0.6945 -0.405,1.2895 -0.6179,1.9602 -0.4859,1.423 -0.8861,2.6022 -1.4684,3.5983 -0.3265,0.4816 -0.7248,0.5408 -1.091,0.6599 l 2.0701,3.4738 3.8112,-9.0802 -2.4239,-1.1866 z"
id="path174"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.07454,-0.15477,0.16465,0.0793,0,0)"
id="g176"><path
d="m -4951.7379,3483.9904 c -1.0953,0 -2.6683,-0.049 -3.7196,-0.014 -4.4074,0.1565 -7.7871,1.0633 -11.8438,1.6036 -8.687,0.987 -15.8847,1.8128 -22.5799,1.3073 -3.3508,-0.4663 -4.6681,-2.2904 -6.2186,-3.8114 l -12.989,18.4538 57.2508,-2.7706 0.1001,-14.7688 z"
id="path178"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 219.1056,1072.1339 -0.6173,-2.6771 -19.7252,4.3226 0.868,3.9727 19.4745,-5.6182 z"
id="path180"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.03822,0.16747,-0.17816,0.04066,0,0)"
id="g182"><path
d="m 6368.633,136.4414 -15.9914,0.0349 -1.0165,110.4948 23.6699,0.206 -6.662,-110.7357 z"
id="path184"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 218.0798,1067.6375 0.6046,2.6794 -19.6481,4.659 -0.9405,-3.9555 19.984,-3.3829 z"
id="path186"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.03822,0.16747,-0.17816,0.04066,0,0)"
id="g188"><path
d="m 6341.7858,136.44 15.9894,0.0363 0.993,110.4933 -23.6673,0.2019 6.6849,-110.7315 z"
id="path190"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 225.5496,1066.1054 c -1.279,0.2923 -2.103,1.4613 -1.8405,2.6127 0.2631,1.1517 1.5126,1.8479 2.7913,1.5562 1.2793,-0.2914 2.1036,-1.4609 1.8411,-2.6127 -0.2631,-1.1514 -1.5123,-1.8482 -2.7919,-1.5562"
id="path192"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.03657,0.16035,-0.17817,0.04063,0,0)"
id="g194"><path
d="m 6624.6812,93.8699 c 0,7.1821 5.8189,12.9977 13.0011,12.9988 7.1796,-0.003 12.9974,-5.8215 12.9971,-12.9986 0,-7.1795 -5.8161,-13.0019 -12.9985,-13.0013 -7.1813,0.0022 -13.0012,5.8223 -12.9997,13.0011 z"
id="path196"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 226.531,1070.2664 c -0.1826,0.042 -0.4439,0.1105 -0.6225,0.1443 -0.7435,0.1411 -1.3462,0.1085 -2.048,0.1669 -1.4947,0.1562 -2.7346,0.2844 -3.8345,0.6305 -0.5422,0.2103 -0.6891,0.5862 -0.8869,0.9164 l -2.9251,-2.7918 9.7005,-1.6937 0.6165,2.6274 z"
id="path198"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.16748,-0.03822,0.04066,0.17817,0,0)"
id="g200"><path
d="m -100.5092,5985.5941 c -1.0916,-2e-4 -2.6645,0.05 -3.7196,0.012 -4.4028,-0.1522 -7.7808,-1.0598 -11.8414,-1.6029 -8.684,-0.9862 -15.8879,-1.8139 -22.5803,-1.3054 -3.3477,0.4654 -4.6655,2.2895 -6.2161,3.8103 l -12.9872,-18.4544 57.2485,2.7726 0.0961,14.7679 z"
id="path202"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 225.5803,1066.0992 c -0.1834,0.042 -0.4485,0.093 -0.624,0.14 -0.731,0.1953 -1.26,0.4859 -1.9176,0.7379 -1.4148,0.5074 -2.5869,0.93 -3.7281,1.0953 -0.5794,0.046 -0.8754,-0.2288 -1.1965,-0.4405 l -1.4247,3.7839 9.4748,-2.6821 -0.5839,-2.6345 z"
id="path204"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.16748,-0.03822,0.04066,0.17817,0,0)"
id="g206"><path
d="m -100.5077,5962.2049 c -1.0954,6e-4 -2.6652,-0.052 -3.7225,-0.013 -4.4022,0.1536 -7.7803,1.0581 -11.8358,1.6027 -8.6899,0.9836 -15.8896,1.8116 -22.5808,1.3036 -3.3505,-0.4626 -4.6715,-2.2858 -6.22,-3.8066 l -12.9867,18.4527 57.2477,-2.7737 0.0981,-14.766 z"
id="path208"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 211.6429,1095.893 1.7084,-2.1515 -15.6779,-12.7267 -2.5639,3.1547 16.5334,11.7235 z"
id="path210"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.10711,-0.1343,0.14287,0.11395,0,0)"
id="g212"><path
d="m -4219.3791,4644.5956 15.993,-0.032 1.012,-110.4928 -23.6625,-0.208 6.6575,110.7329 z"
id="path214"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 214.52,1092.2873 -1.7192,2.1436 -15.8913,-12.4566 2.5053,-3.2014 15.1052,13.5144 z"
id="path216"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.10711,-0.1343,0.14287,0.11395,0,0)"
id="g218"><path
d="m -4192.5257,4644.6018 -15.9959,-0.041 -0.9899,-110.4863 23.6639,-0.2055 -6.6781,110.7329 z"
id="path220"
style="fill:none;stroke:#ffffff;stroke-width:0.41159999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 220.3747,1097.1729 c -1.0256,-0.8181 -2.4542,-0.7331 -3.1901,0.1902 -0.7364,0.9229 -0.5017,2.3349 0.5233,3.1529 1.0261,0.8181 2.4542,0.7331 3.1909,-0.1899 0.7359,-0.923 0.5018,-2.3352 -0.5241,-3.1532"
id="path222"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.10257,-0.12857,0.14286,0.11397,0,0)"
id="g224"><path
d="m -4379.2058,4686.834 c -3e-4,-7.1787 -5.8215,-12.9999 -13,-12.9971 -7.179,-6e-4 -13,5.8218 -13.0017,12.998 0,7.1813 5.8204,13.0011 13.0009,13.0005 7.1778,-5e-4 13.0022,-5.8192 13.0008,-13.0014 z"
id="path226"
style="fill:none;stroke:#ffffff;stroke-width:0.2744;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 217.7337,1100.5347 c -0.1471,-0.1173 -0.364,-0.2786 -0.5012,-0.3962 -0.5737,-0.4938 -0.9241,-0.9859 -1.4068,-1.4976 -1.0554,-1.0718 -1.9273,-1.9613 -2.8843,-2.6053 -0.5026,-0.2925 -0.8872,-0.1735 -1.2691,-0.1216 l 0.3586,-4.028 7.3724,6.5284 -1.6696,2.1203 z"
id="path228"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.1343,0.10711,-0.11395,0.14287,0,0)"
id="g230"><path
d="m 4985.5978,3965.3263 c -1.097,8e-4 -2.6683,0.052 -3.7208,0.016 -4.4036,-0.1551 -7.7842,-1.0647 -11.8383,-1.6067 -8.6933,-0.9845 -15.8919,-1.8139 -22.5811,-1.3048 -3.3517,0.4632 -4.6689,2.2839 -6.2198,3.8098 l -12.9886,-18.4561 57.2496,2.7757 0.099,14.7665 z"
id="path232"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 220.3994,1097.193 c -0.1474,-0.1171 -0.3532,-0.2926 -0.4984,-0.4006 -0.6088,-0.4498 -1.1664,-0.6814 -1.7733,-1.0391 -1.2784,-0.7898 -2.34,-1.4429 -3.1811,-2.2323 -0.3968,-0.4247 -0.3662,-0.8266 -0.4008,-1.2101 l -3.8472,1.2452 8.0045,5.7362 1.6963,-2.0993 z"
id="path234"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><g
transform="matrix(0.1343,0.10711,-0.11395,0.14287,0,0)"
id="g236"><path
d="m 4985.5986,3941.9357 c -1.0956,0 -2.6665,-0.048 -3.7216,-0.013 -4.4042,0.1528 -7.7836,1.0656 -11.8429,1.6047 -8.6839,0.9848 -15.887,1.8114 -22.5788,1.3028 -3.3499,-0.4629 -4.6672,-2.2867 -6.2169,-3.8072 l -12.9903,18.4524 57.2507,-2.7706 0.1,-14.7687 z"
id="path238"
style="fill:none;stroke:#ffffff;stroke-width:0.26840001;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><path
d="m 187.367,1086.9849 c -0.0426,-1.0035 -0.868,-1.8049 -1.8822,-1.8049 -0.4156,0 -0.7988,0.1338 -1.1101,0.3606 l -0.489,-0.2324 1.0012,-2.0696 4.3855,2.1152 -0.9958,2.0693 -0.9096,-0.4382 z"
id="path240"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 180.2086,1080.3039 c 0.7586,-0.6588 0.8697,-1.8043 0.2379,-2.5971 -0.2591,-0.3243 -0.603,-0.5409 -0.9746,-0.6429 l -0.1227,-0.5276 2.2419,-0.5076 1.0811,4.7477 -2.2393,0.5119 -0.2243,-0.9844 z"
id="path242"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 180.9609,1070.5462 c 0.9874,0.182 1.9525,-0.4448 2.1782,-1.4335 0.0927,-0.4045 0.0476,-0.8087 -0.1052,-1.1628 l 0.3365,-0.4243 1.7952,1.4357 -3.039,3.805 -1.7958,-1.4315 0.6301,-0.7886 z"
id="path244"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 189.059,1065.0538 c 0.4731,0.8861 1.5653,1.2495 2.4786,0.8095 0.3739,-0.1797 0.6613,-0.4665 0.8438,-0.8064 l 0.5415,0 -0.004,2.2986 -4.8699,0 0,-2.2975 1.0097,6e-4 z"
id="path246"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 198.3934,1067.993 c -0.3971,0.9233 -8e-4,2.003 0.9131,2.4426 0.3739,0.1809 0.777,0.2262 1.1562,0.1562 l 0.3391,0.4227 -1.7989,1.4309 -3.0339,-3.8095 1.7954,-1.4326 0.629,0.7897 z"
id="path248"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 201.9577,1077.1194 c -0.9688,0.2648 -1.5661,1.2481 -1.3408,2.2366 0.0922,0.4045 0.3079,0.7489 0.5987,1.0023 l -0.1182,0.5284 -2.2399,-0.5148 1.0862,-4.7472 2.2394,0.5103 -0.2254,0.9844 z"
id="path250"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 197.0442,1085.5809 c -0.811,-0.5922 -1.9525,-0.4462 -2.5844,0.3469 -0.2588,0.324 -0.394,0.7073 -0.4104,1.0928 l -0.4868,0.2369 -0.9935,-2.0726 4.388,-2.1104 0.9975,2.0695 -0.9104,0.4369 z"
id="path252"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 281.6892,1072.3652 c 0.7671,0.8949 1.5449,1.8431 2.3332,2.8442 0.7883,1.0015 1.5554,2.035 2.3012,3.1003 0.7458,1.0653 1.4595,2.0988 2.1413,3.1003 0.682,1.0014 1.2784,1.9496 1.7898,2.8445 l 9.4603,0 c -0.767,-0.9802 -1.6407,-2.0455 -2.6206,-3.196 -0.9802,-1.1506 -1.9922,-2.3228 -3.0365,-3.5159 -1.044,-1.1931 -2.088,-2.3436 -3.132,-3.4517 -1.044,-1.1078 -1.9922,-2.1305 -2.8445,-3.0682 1.0655,-1.0228 2.2161,-2.2479 3.4517,-3.6754 1.2359,-1.4276 2.4503,-2.9084 3.6437,-4.4425 1.1931,-1.5341 2.2903,-3.0682 3.2918,-4.6023 1.0015,-1.5341 1.8003,-2.8979 2.397,-4.091 l -9.0127,0 c -0.5114,1.0653 -1.1827,2.2692 -2.0138,3.6116 -0.8308,1.3423 -1.7149,2.6632 -2.6526,3.9632 -0.9375,1.2997 -1.8856,2.5353 -2.8443,3.7074 -0.959,1.1718 -1.8431,2.1413 -2.653,2.9083 l 0,-14.1905 -7.9262,0 0,43.0189 7.9262,1.3422 0,-26.2074 z"
id="path254"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 329.694,1055.2343 c -1.4491,-0.3836 -3.2069,-0.7671 -5.2736,-1.1506 -2.0668,-0.3835 -4.3146,-0.5752 -6.7436,-0.5752 -2.4719,0 -4.4958,0.3408 -6.0727,1.0225 -1.5766,0.682 -2.823,1.6515 -3.7392,2.9086 -0.9161,1.2572 -1.5449,2.738 -1.8859,4.4425 -0.3407,1.7045 -0.5113,3.5796 -0.5113,5.625 l 0,16.7474 7.8624,0 0,-15.7246 c 0,-2.77 0.3302,-4.826 0.9907,-6.1685 0.6605,-1.3422 1.9497,-2.0134 3.8673,-2.0134 1.1931,0 2.3862,0.1066 3.5796,0.3194 l 0,23.5871 7.9263,0 0,-29.0202 z"
id="path256"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 355.7095,1069.4248 c 0,2.8125 -0.4581,4.9646 -1.3743,6.4559 -0.9161,1.4916 -2.3119,2.2374 -4.1867,2.2374 -0.8524,0 -1.694,-0.1174 -2.5248,-0.3518 -0.8312,-0.2341 -1.5449,-0.5219 -2.1416,-0.8629 l 0,-16.2997 c 0.5967,-0.1279 1.2251,-0.2132 1.8859,-0.2557 0.6604,-0.043 1.2251,-0.064 1.6937,-0.064 2.0454,0 3.6649,0.6925 4.858,2.0775 1.1931,1.385 1.7898,3.7395 1.7898,7.0634 z m 7.9903,-0.1919 c 0,-2.3862 -0.3198,-4.5491 -0.959,-6.488 -0.6392,-1.9389 -1.5766,-3.59 -2.8125,-4.9538 -1.2359,-1.3637 -2.7485,-2.4182 -4.5383,-3.164 -1.7898,-0.7458 -3.8353,-1.1186 -6.1364,-1.1186 -2.0455,0 -4.1338,0.1491 -6.2643,0.4473 -2.1308,0.2982 -3.9206,0.6818 -5.3694,1.1506 l 0,42.124 7.8622,1.3422 0,-15.0214 c 1.108,0.5114 2.1733,0.8629 3.196,1.0548 1.0228,0.1916 2.0455,0.2877 3.0683,0.2877 1.9604,0 3.6861,-0.373 5.1777,-1.1188 1.4913,-0.7458 2.738,-1.8111 3.7392,-3.1961 1.0015,-1.3847 1.7581,-3.0362 2.2694,-4.9538 0.5114,-1.9176 0.7671,-4.0481 0.7671,-6.3921"
id="path258"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 367.5986,1068.9772 c 0,2.6422 0.405,4.9646 1.2146,6.9676 0.8096,2.0026 1.8751,3.6754 3.1961,5.0176 1.3209,1.3425 2.8338,2.3544 4.5382,3.0364 1.7048,0.6818 3.4518,1.0228 5.2416,1.0228 4.4319,0 7.7984,-1.3105 10.0995,-3.9314 2.3012,-2.6206 3.4518,-6.4451 3.4518,-11.4738 0,-0.5114 -0.0108,-1.044 -0.0321,-1.5979 -0.0212,-0.5542 -0.0532,-1.0015 -0.0958,-1.3425 l -19.4958,0 c 0,-1.9601 0.8096,-3.505 2.429,-4.634 1.6192,-1.1294 3.7074,-1.694 6.2643,-1.694 1.5766,0 3.0787,0.1703 4.5062,0.5113 1.4278,0.341 2.6314,0.6818 3.6116,1.0228 l 1.0868,-6.7119 c -1.3637,-0.4686 -2.8125,-0.8629 -4.3466,-1.1823 -1.5341,-0.3198 -3.2601,-0.4794 -5.1778,-0.4794 -2.5568,0 -4.8472,0.3303 -6.8714,0.9907 -2.0242,0.6605 -3.75,1.6407 -5.1775,2.9404 -1.4275,1.2997 -2.5251,2.9084 -3.2922,4.826 -0.767,1.9176 -1.1505,4.1547 -1.1505,6.7116 z m 20.1353,3.1323 c 0,0.8096 -0.1066,1.5874 -0.3198,2.3329 -0.2131,0.7458 -0.5538,1.417 -1.0227,2.0137 -0.4686,0.5964 -1.0653,1.0761 -1.7898,1.438 -0.7242,0.3623 -1.6191,0.5434 -2.6847,0.5434 -1.0227,0 -1.9069,-0.1703 -2.6526,-0.5113 -0.7458,-0.341 -1.3638,-0.8096 -1.8536,-1.4063 -0.4901,-0.5967 -0.8737,-1.2784 -1.1506,-2.0455 -0.2772,-0.767 -0.4581,-1.5553 -0.5434,-2.3649 l 12.0172,0 z"
id="path260"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 425.5109,1076.2642 c -0.5113,0.1279 -1.1185,0.2557 -1.8218,0.3835 -0.703,0.1279 -1.4168,0.2452 -2.1413,0.3515 -0.7245,0.1066 -1.4275,0.1812 -2.1092,0.224 -0.6821,0.043 -1.2572,0.064 -1.7261,0.064 -1.1077,0 -2.1945,-0.053 -3.2598,-0.1599 -1.0656,-0.1063 -2.1521,-0.309 -3.2601,-0.6072 l 0,-22.3084 -7.9263,0 0,28.0613 c 2.0883,0.7671 4.2296,1.385 6.4242,1.8539 2.1946,0.4685 4.7622,0.703 7.7026,0.703 0.426,0 1.0332,-0.021 1.8215,-0.064 0.7886,-0.043 1.6302,-0.1174 2.5251,-0.2239 0.8949,-0.1066 1.8003,-0.2345 2.7165,-0.3836 0.9161,-0.1491 1.7365,-0.3515 2.461,-0.6072 l -1.4063,-7.287 z"
id="path262"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 433.5647,1083.2956 c 1.4063,0.3835 3.1428,0.7458 5.2098,1.0868 2.0668,0.3407 4.3146,0.5113 6.7436,0.5113 2.3862,0 4.3679,-0.3305 5.9446,-0.991 1.5766,-0.6604 2.8233,-1.5978 3.7394,-2.8125 0.9162,-1.2144 1.5662,-2.6631 1.9497,-4.3466 0.3835,-1.6833 0.5752,-3.5476 0.5752,-5.5931 l 0,-16.939 -7.8622,0 0,15.9163 c 0,2.8125 -0.3198,4.8367 -0.959,6.0726 -0.6392,1.2357 -1.9389,1.8536 -3.899,1.8536 -0.5967,0 -1.1826,-0.021 -1.7578,-0.064 -0.5754,-0.043 -1.1826,-0.1065 -1.8218,-0.1919 l 0,-23.5868 -7.8625,0 0,29.0841 z"
id="path264"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 463.4796,1068.9772 c 0,2.6422 0.4051,4.9646 1.2146,6.9676 0.8096,2.0026 1.8752,3.6754 3.1961,5.0176 1.3209,1.3425 2.8338,2.3544 4.5383,3.0364 1.7047,0.6818 3.4517,1.0228 5.2415,1.0228 4.432,0 7.7984,-1.3105 10.0996,-3.9314 2.3011,-2.6206 3.4517,-6.4451 3.4517,-11.4738 0,-0.5114 -0.0108,-1.044 -0.032,-1.5979 -0.0213,-0.5542 -0.0533,-1.0015 -0.0958,-1.3425 l -19.4959,0 c 0,-1.9601 0.8096,-3.505 2.429,-4.634 1.6192,-1.1294 3.7075,-1.694 6.2643,-1.694 1.5767,0 3.0787,0.1703 4.5063,0.5113 1.4278,0.341 2.6314,0.6818 3.6116,1.0228 l 1.0868,-6.7119 c -1.3638,-0.4686 -2.8126,-0.8629 -4.3467,-1.1823 -1.5341,-0.3198 -3.2601,-0.4794 -5.1777,-0.4794 -2.5569,0 -4.8473,0.3303 -6.8715,0.9907 -2.0242,0.6605 -3.7499,1.6407 -5.1775,2.9404 -1.4275,1.2997 -2.5251,2.9084 -3.2921,4.826 -0.7671,1.9176 -1.1506,4.1547 -1.1506,6.7116 z m 20.1353,3.1323 c 0,0.8096 -0.1066,1.5874 -0.3197,2.3329 -0.2132,0.7458 -0.5539,1.417 -1.0228,2.0137 -0.4685,0.5964 -1.0652,1.0761 -1.7898,1.438 -0.7242,0.3623 -1.6191,0.5434 -2.6846,0.5434 -1.0228,0 -1.9069,-0.1703 -2.6527,-0.5113 -0.7458,-0.341 -1.3638,-0.8096 -1.8536,-1.4063 -0.4901,-0.5967 -0.8736,-1.2784 -1.1506,-2.0455 -0.2772,-0.767 -0.458,-1.5553 -0.5434,-2.3649 l 12.0172,0 z"
id="path266"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 502.5991,1077.7346 -6.8394,0 0,6.5199 6.8394,0 0,7.5424 7.8625,1.2785 0,-8.8209 12.5923,0 0,-6.5199 -12.5923,0 0,-12.1451 c 0,-1.1081 0.1066,-2.0029 0.3194,-2.6847 0.2132,-0.6817 0.5114,-1.2146 0.8949,-1.5982 0.3836,-0.3835 0.8524,-0.6392 1.4063,-0.767 0.5542,-0.1279 1.1718,-0.1916 1.8539,-0.1916 0.7242,0 1.3955,0.021 2.0134,0.064 0.618,0.043 1.2144,0.1174 1.7898,0.224 0.5752,0.1063 1.1718,0.2662 1.7898,0.4793 0.618,0.2132 1.2889,0.4901 2.0135,0.8309 l 1.0868,-6.7757 c -1.4491,-0.5964 -3.0153,-1.0225 -4.6985,-1.2781 -1.6832,-0.2557 -3.3131,-0.3836 -4.8897,-0.3836 -1.8326,0 -3.4518,0.1491 -4.8581,0.4473 -1.4062,0.2982 -2.5996,0.8737 -3.5795,1.7258 -0.9803,0.8524 -1.7261,2.0562 -2.2374,3.6116 -0.5114,1.5554 -0.7671,3.5904 -0.7671,6.1044 l 0,12.337 z"
id="path268"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 527.4003,1068.9772 c 0,2.6422 0.4051,4.9646 1.2146,6.9676 0.8096,2.0026 1.8751,3.6754 3.1961,5.0176 1.3209,1.3425 2.8338,2.3544 4.5383,3.0364 1.7047,0.6818 3.4517,1.0228 5.2415,1.0228 4.432,0 7.7984,-1.3105 10.0996,-3.9314 2.3011,-2.6206 3.4517,-6.4451 3.4517,-11.4738 0,-0.5114 -0.0108,-1.044 -0.032,-1.5979 -0.0213,-0.5542 -0.0533,-1.0015 -0.0958,-1.3425 l -19.4959,0 c 0,-1.9601 0.8096,-3.505 2.429,-4.634 1.6192,-1.1294 3.7075,-1.694 6.2643,-1.694 1.5766,0 3.0787,0.1703 4.5063,0.5113 1.4278,0.341 2.6314,0.6818 3.6116,1.0228 l 1.0868,-6.7119 c -1.3638,-0.4686 -2.8126,-0.8629 -4.3467,-1.1823 -1.5341,-0.3198 -3.2601,-0.4794 -5.1777,-0.4794 -2.5569,0 -4.8473,0.3303 -6.8715,0.9907 -2.0242,0.6605 -3.7499,1.6407 -5.1775,2.9404 -1.4275,1.2997 -2.5251,2.9084 -3.2921,4.826 -0.7671,1.9176 -1.1506,4.1547 -1.1506,6.7116 z m 20.1353,3.1323 c 0,0.8096 -0.1066,1.5874 -0.3197,2.3329 -0.2132,0.7458 -0.5539,1.417 -1.0228,2.0137 -0.4685,0.5964 -1.0652,1.0761 -1.7898,1.438 -0.7242,0.3623 -1.6191,0.5434 -2.6847,0.5434 -1.0227,0 -1.9068,-0.1703 -2.6526,-0.5113 -0.7458,-0.341 -1.3638,-0.8096 -1.8536,-1.4063 -0.4901,-0.5967 -0.8736,-1.2784 -1.1506,-2.0455 -0.2772,-0.767 -0.4581,-1.5553 -0.5434,-2.3649 l 12.0172,0 z"
id="path270"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /><path
d="m 571.9533,1060.1561 c 1.9176,0 3.3876,0.1386 4.4104,0.4155 1.0227,0.277 1.5341,0.8416 1.5341,1.694 0,0.5539 -0.1599,1.0227 -0.4793,1.4063 -0.3198,0.3835 -0.7671,0.7137 -1.3425,0.9907 -0.5752,0.2769 -1.2357,0.5434 -1.9814,0.7991 -0.7458,0.2557 -1.5234,0.5113 -2.3332,0.767 -1.1506,0.3407 -2.3225,0.735 -3.5156,1.1826 -1.1931,0.4473 -2.2799,1.012 -3.2601,1.6937 -0.9799,0.6821 -1.7898,1.5449 -2.429,2.5889 -0.6392,1.044 -0.9587,2.3545 -0.9587,3.9311 0,1.2784 0.2449,2.4823 0.735,3.6116 0.4901,1.1294 1.2572,2.1305 2.3012,3.0042 1.044,0.8736 2.3757,1.5554 3.9952,2.0455 1.6191,0.4901 3.5583,0.7353 5.8166,0.7353 1.9605,0 3.782,-0.1494 5.4652,-0.4476 1.6835,-0.2982 3.1428,-0.7246 4.3787,-1.2784 l -1.2143,-6.6479 c -0.7246,0.2132 -1.8539,0.5647 -3.388,1.0548 -1.5341,0.4901 -3.2599,0.735 -5.1775,0.735 -2.003,0 -3.3559,-0.2449 -4.0589,-0.735 -0.7033,-0.4901 -1.0548,-1.0122 -1.0548,-1.5661 0,-0.4689 0.1599,-0.8841 0.4793,-1.2464 0.3198,-0.3623 0.7458,-0.6925 1.2785,-0.9907 0.5326,-0.2985 1.1506,-0.5859 1.8538,-0.8632 0.703,-0.2769 1.4593,-0.5431 2.2692,-0.7988 1.1505,-0.3835 2.3437,-0.8098 3.5796,-1.2784 1.2356,-0.4689 2.3544,-1.0548 3.3556,-1.7578 1.0015,-0.7032 1.8218,-1.5981 2.461,-2.6847 0.6393,-1.0868 0.959,-2.4185 0.959,-3.9951 0,-1.2359 -0.2344,-2.4078 -0.7033,-3.5158 -0.4688,-1.1078 -1.2464,-2.0668 -2.3332,-2.8763 -1.0865,-0.8096 -2.5035,-1.4488 -4.2505,-1.9177 -1.7473,-0.4688 -3.8994,-0.703 -6.4562,-0.703 -2.5994,0 -4.8152,0.2982 -6.6478,0.8946 -1.8323,0.5967 -3.3024,1.1294 -4.4104,1.5982 l 1.2143,6.5838 c 1.4916,-0.5964 3.079,-1.1506 4.7622,-1.662 1.6832,-0.5114 3.3985,-0.767 5.1458,-0.767"
id="path272"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" /></g></svg>

After

Width:  |  Height:  |  Size: 41 KiB

BIN
_images/marathon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
_images/mesos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
_images/network.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
_images/swarm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
_images/virtualization.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

49
_local/.bashrc_docker Normal file
View File

@@ -0,0 +1,49 @@
# Some useful commands to use docker.
# Author: yeasy@github
# Created:2014-09-25
alias docker-pid="sudo docker inspect --format '{{.State.Pid}}'"
alias docker-ip="sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
#the implementation refs from https://github.com/jpetazzo/nsenter/blob/master/docker-enter
function docker-enter() {
#if [ -e $(dirname "$0")/nsenter ]; then
#Change for centos bash running
if [ -e $(dirname '$0')/nsenter ]; then
# with boot2docker, nsenter is not in the PATH but it is in the same folder
NSENTER=$(dirname "$0")/nsenter
else
# if nsenter has already been installed with path notified, here will be clarified
NSENTER=$(which nsenter)
#NSENTER=nsenter
fi
[ -z "$NSENTER" ] && echo "WARN Cannot find nsenter" && return
if [ -z "$1" ]; then
echo "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...]"
echo ""
echo "Enters the Docker CONTAINER and executes the specified COMMAND."
echo "If COMMAND is not specified, runs an interactive shell in CONTAINER."
else
PID=$(sudo docker inspect --format "{{.State.Pid}}" "$1")
if [ -z "$PID" ]; then
echo "WARN Cannot find the given container"
return
fi
shift
OPTS="--target $PID --mount --uts --ipc --net --pid"
if [ -z "$1" ]; then
# No command given.
# Use su to clear all host environment variables except for TERM,
# initialize the environment variables HOME, SHELL, USER, LOGNAME, PATH,
# and start a login shell.
#sudo $NSENTER "$OPTS" su - root
sudo $NSENTER --target $PID --mount --uts --ipc --net --pid su - root
else
# Use env to clear all host environment variables.
sudo $NSENTER --target $PID --mount --uts --ipc --net --pid env -i $@
fi
fi
}

Binary file not shown.

13
_local/pull_all.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
# This script will update all local images
# See: https://github.com/yeasy/docker_practice/blob/master/_local/pull_all.sh
# Usage: pull_all
# Author: yeasy@github
# Create: 2014-09-23
for image in `sudo docker images|grep -v "REPOSITORY"|grep -v "<none>"|awk '{print $1":"$2}'`
do
sudo docker pull $image
done

12
_local/push_all.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# This script will upload all local images to a registry server ($registry is the default value).
# This script requires the push_images, which can be found at https://github.com/yeasy/docker_practice/blob/master/_local/push_images.sh
# Usage: push_all
# Author: yeasy@github
# Create: 2014-09-23
for image in `sudo docker images|grep -v "REPOSITORY"|grep -v "<none>"|awk '{print $1":"$2}'`
do
push_images $image
done

47
_local/push_images.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/sh
# This script will upload the given local images to a registry server ($registry is the default value).
# See: https://github.com/yeasy/docker_practice/blob/master/_local/push_images.sh
# Usage: push_images image1 [image2...]
# Author: yeasy@github
# Create: 2014-09-23
#The registry server address where you want push the images into
registry=127.0.0.1:5000
### DO NOT MODIFY THE FOLLOWING PART, UNLESS YOU KNOW WHAT IT MEANS ###
echo_r () {
[ $# -ne 1 ] && return 0
echo -e "\033[31m$1\033[0m"
}
echo_g () {
[ $# -ne 1 ] && return 0
echo -e "\033[32m$1\033[0m"
}
echo_y () {
[ $# -ne 1 ] && return 0
echo -e "\033[33m$1\033[0m"
}
echo_b () {
[ $# -ne 1 ] && return 0
echo -e "\033[34m$1\033[0m"
}
usage() {
sudo docker images
echo "Usage: $0 registry1:tag1 [registry2:tag2...]"
}
[ $# -lt 1 ] && usage && exit
echo_b "The registry server is $registry"
for image in "$@"
do
echo_b "Uploading $image..."
sudo docker tag $image $registry/$image
sudo docker push $registry/$image
sudo docker rmi $registry/$image
echo_g "Done"
done

View File

@@ -1,9 +1,12 @@
#docker高级网络配置
当docker启动时会在主机上创建一个docker0的虚拟网卡。他随机挑选RFC1918私有网络中的一段地址给docker0。比如172.17.42.1/16,16位掩码的网段可以拥有65534个地址可以使用这对主机和容器来说应该足够了
注意本章介绍docker的高级网络配置一般情况下你不需要知道这些也可以使docker正常工作。简单的网络配置和介绍请看第五章内容。
docker0 不是普通的网卡他是桥接到其他网卡的虚拟网卡容器使用它来和主机相互通信。当创建一个docker容器的时候它就创建了一个对接口当数据包发送到一个接口时另外一个接口也可以收到相同的数据包它们是绑在一起的一对孪生接口。这对接口在容器中那一端的的名字是eth0宿主主机端的会指定一个唯一的名字比如vethAQI2QT这样的名字这种接口名字不再主机的命名空间中。所有的veth*的接口都会桥接到docker0这样docker就创建了在主机和所有容器之间一个虚拟共享网络。
# 高级网络配置
本章将介绍 Docker 的一些高级网络配置和选项
当 Docker 启动时,会自动在主机上创建一个 `docker0` 虚拟网桥,实际上是 Linux 的一个 bridge可以理解为一个软件交换机。它会在挂载到它的网口之间进行转发。
![Docker网络](../images/docker0.png)
同时,Docker 随机分配一个本地未占用的私有网段(在 [RFC1918](http://tools.ietf.org/html/rfc1918) 中定义)中的一个地址给 `docker0` 接口。比如典型的 `172.17.42.1`,掩码为 `255.255.0.0`。此后启动的容器内的网口也会自动分配一个同一网段(`172.17.0.0/16`)的地址。
接下来的部分将介绍在一些场景中docker所有的网络定制配置。linux的原生命令将调整、补充、甚至替换docker默认的网络配置
当创建一个 Docker 容器的时候,同时会创建了一对 `veth pair` 接口(当数据包发送到一个接口时,另外一个接口也可以收到相同的数据包)。这对接口一端在容器内,即 `eth0`;另一端在本地并被挂载到 `docker0` 网桥,名称以 `veth` 开头(例如 `vethAQI2QT`。通过这种方式主机可以跟容器通信容器之间也可以相互通信。Docker 就创建了在主机和所有容器之间一个虚拟共享网络
![Docker 网络](../_images/network.png)
接下来的部分将介绍在一些场景中Docker 所有的网络定制配置。以及通过 Linux 命令来调整、补充、甚至替换 Docker 默认的网络配置。

View File

@@ -0,0 +1,55 @@
## 容器访问控制
容器的访问控制,主要通过 Linux 上的 `iptables` 防火墙来进行管理和实现。`iptables` 是 Linux 上默认的防火墙软件,在大部分发行版中都自带。
### 容器访问外部网络
容器要想访问外部网络需要本地系统的转发支持。在Linux 系统中,检查转发是否打开。
```
$sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
```
如果为 0说明没有开启转发则需要手动打开。
```
$sysctl -w net.ipv4.ip_forward=1
```
如果在启动 Docker 服务的时候设定 `--ip-forward=true`, Docker 就会自动设定系统的 `ip_forward` 参数为 1。
### 容器之间访问
容器之间相互访问,需要两方面的支持。
* 容器的网络拓扑是否已经互联。默认情况下,所有容器都会被连接到 `docker0` 网桥上。
* 本地系统的防火墙软件 -- `iptables` 是否允许通过。
#### 访问所有端口
当启动 Docker 服务时候,默认会添加一条转发策略到 iptables 的 FORWARD 链上。策略为通过(`ACCEPT`)还是禁止(`DROP`)取决于配置`--icc=true`(缺省值)还是 `--icc=false`。当然,如果手动指定 `--iptables=false` 则不会添加 `iptables` 规则。
可见,默认情况下,不同容器之间是允许网络互通的。如果为了安全考虑,可以在 `/etc/default/docker` 文件中配置 `DOCKER_OPTS=--icc=false` 来禁止它。
#### 访问指定端口
在通过 `-icc=false` 关闭网络访问后,还可以通过 `--link=CONTAINER_NAME:ALIAS` 选项来访问容器的开放端口。
例如,在启动 Docker 服务时,可以同时使用 `icc=false --iptables=true` 参数来关闭允许相互的网络访问,并让 Docker 可以修改系统中的 `iptables` 规则。
此时,系统中的 `iptables` 规则可能是类似
```
$ sudo iptables -nL
...
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DROP all -- 0.0.0.0/0 0.0.0.0/0
...
```
之后,启动容器(`docker run`)时使用 `--link=CONTAINER_NAME:ALIAS` 选项。Docker 会在 `iptable` 中为 两个容器分别添加一条 `ACCEPT` 规则,允许相互访问开放的端口(取决于 Dockerfile 中的 EXPOSE 行)。
当添加了 `--link=CONTAINER_NAME:ALIAS` 选项后,添加了 `iptables` 规则。
```
$ sudo iptables -nL
...
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 172.17.0.2 172.17.0.3 tcp spt:80
ACCEPT tcp -- 172.17.0.3 172.17.0.2 tcp dpt:80
DROP all -- 0.0.0.0/0 0.0.0.0/0
```
注意:`--link=CONTAINER_NAME:ALIAS` 中的 `CONTAINER_NAME` 目前必须是 Docker 分配的名字,或使用 `--name` 参数指定的名字。主机名则不会被识别。

View File

@@ -1,31 +1,34 @@
##创建自己的桥接
如果希望完全使用自己的桥接设置可以在启动docker服务的时候使用 -b BRIDGE or --bridge=BRIDGE 来告诉docker使用你的网桥。如果服务已经启动旧的网桥还在使用中那需要先停止服务再删除旧的网桥
## 自定义网桥
除了默认的 `docker0` 网桥,用户也可以指定网桥来连接各个容器。
在启动 Docker 服务的时候,使用 `-b BRIDGE``--bridge=BRIDGE` 来指定使用的网桥。
如果服务已经运行,那需要先停止服务,并删除旧的网桥。
```
#停止旧网桥并删除
$ sudo service docker stop
$ sudo ip link set dev docker0 down
$ sudo brctl delbr docker0
```
然后在开启服务前,创建你自己希望的网桥接口,这里建立一个网桥的配置:
然后创建一个网桥 `bridge0`
```
# 创建自己的网桥
$ sudo brctl addbr bridge0
$ sudo ip addr add 192.168.5.1/24 dev bridge0
$ sudo ip link set dev bridge0 up
```
查看确认网桥创建并启动。
```
# 确认网桥启动
$ ip addr show bridge0
4: bridge0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP group default
link/ether 66:38:d0:0d:76:18 brd ff:ff:ff:ff:ff:ff
inet 192.168.5.1/24 scope global bridge0
valid_lft forever preferred_lft forever
```
配置 Docker 服务,默认桥接到创建的网桥上。
```
# 告诉docker桥接设置并启动docker服务在ubuntu上
$ echo 'DOCKER_OPTS="-b=bridge0"' >> /etc/default/docker
$ sudo service docker start
```
docker服务启动成功并绑定容器到新的网桥新建一个容器你会看到它的ip是我们的设置的新ip段docker会自动检测到它。用brctl
show可以看到容器启动或则停止后网桥的配置变化在容器中使用```ip addr```和```ip route```来查看ip地址配置和路由信息
启动 Docker 服务。
新建一个容器,可以看到它已经桥接到了 `bridge0`
可以继续用 `brctl show` 命令查看桥接的信息。另外,在容器中可以使用 `ip addr``ip route` 命令来查看 IP 地址配置和路由信息。

View File

@@ -1,39 +0,0 @@
##容器之间的通信
判断2个容器之间是否能够通信在操作系统层面取决于3个因素
* 网络拓扑是否连接到容器的网络接口默认docker会将所有的容器连接到docker0这网桥来提供数据包通信。其他拓扑结构将在稍后的文档中详细介绍。
* 主机是否开启ip转发ip_forward参数为1的时候可以提供数据包转发。通常你只需要为docker 设定 --ip-forward=true,
docker 就会在服务启动的时候设定ip_forward参数为1。下面是手工检查并手工设定该参数的方法。
```
# Usually not necessary: turning on forwarding,
# on the host where your Docker server is running
$ cat /proc/sys/net/ipv4/ip_forward
0
$ sudo echo 1 > /proc/sys/net/ipv4/ip_forward
$ cat /proc/sys/net/ipv4/ip_forward
1
```
*你的iptables是否允许这条特殊的连接被建立当docker的设定--iptables=false时docker不会改变系统的iptables
设定,否则它会在--icc=true的时候添加一条默认的ACCEPT策略到 FORWARD链当—icc=false时策略为DROP。几乎所有的人都会开启ip_forward来启用容器间的通信。但是否要改变icc-true配置是一个战略问题。这样iptable就可以防止其他被感染容器对宿主主机的恶意端口扫描和访问。
当你选择更安全的设定--icc=false后如何保持你希望的容器之间通信呢
答案就是--link=CONTAINER_NAME:ALIAS选项在之前的dns服务设定中提及过。如果docker 使用icc=false and --iptables=true 2个参数当docker run使用--link=选型时docker会为2个容器在iptable中参数一对ACCEPT规则开放的端口取决与dockerfile中的EXPOSE行详见第五章。
注意:--link= 中的CONTAINER_NAME 必须是自动生成的docker名字比如stupefied_pare或者你用--name参数指定的名字主机名在--link中不会被识别。
你可以使用iptables命令来检查FORWARD链是ACCEPT 还是DROP
当--icc=false时默认规则应该是这样
```
$ sudo iptables -L -n
...
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DROP all -- 0.0.0.0/0 0.0.0.0/0
...
```
当添加了--link后ACCEPT规则被改写了添加了新的端口和IP规则
```
$ sudo iptables -L -n
...
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 172.17.0.2 172.17.0.3 tcp spt:80
ACCEPT tcp -- 172.17.0.3 172.17.0.2 tcp dpt:80
DROP all -- 0.0.0.0/0 0.0.0.0/0
```

View File

@@ -0,0 +1,5 @@
## 编辑网络配置文件
Docker 1.2.0 开始支持在运行中的容器里编辑 `/etc/hosts`, `/etc/hostname``/etc/resolve.conf` 文件。
但是这些修改是临时的,只在运行的容器中保留,容器终止或重启后并不会被保存下来。也不会被 `docker commit` 提交。

View File

@@ -1,5 +1,8 @@
##配置DNS
docker没有定制为每个容器定制image是怎么提供容器的主机名和dns配置呢秘诀就是它用主机上的3个配置文件来覆盖容器的这3个文件在容器中使用mount命令可以看到
## 配置 DNS
Docker 没有为每个容器专门定制镜像,那么怎么自定义配置容器的主机名和 DNS 配置呢?
秘诀就是它利用虚拟文件来挂载到来容器的 3 个相关配置文件。
在容器中使用 mount 命令可以看到挂载信息:
```
$ mount
...
@@ -8,18 +11,19 @@ $ mount
tmpfs on /etc/resolv.conf type tmpfs ...
...
```
这种机制可以让宿主主机从dhcp更新dns信息后马上更新所有docker容器的dns配置。如果要保持docker中这些文件固定不变你可以不覆盖容器中的这些配置文件然后使用下面的选项来配置它们
配置容器dns服务的方法
这种机制可以让宿主主机 DNS 信息发生更新后,所有 Docker 容器的 dns 配置通过 `/etc/resolv.conf` 文件立刻得到更新
-h HOSTNAME or --hostname=HOSTNAME
设定容器的主机名,它会被写到/etc/hostname/etc/hosts中的ip地址自动写成分配的ip地址在/bin/bash中显示该主机名。但它不会在docker ps中显示也不会在其他的容器的/etc/hosts中显示。
如果用户想要手动指定容器的配置,可以利用下面的选项。
--link=CONTAINER_NAME:ALIAS
这选项会在创建容器的时候添加一个其他容器CONTAINE_NAME的主机名到/etc/hosts文件中让新容器的进程可以使用主机名ALIAS就可以连接它。--link=会在容器之间的通信中更详细的介绍
`-h HOSTNAME or --hostname=HOSTNAME`
设定容器的主机名,它会被写到容器内的 `/etc/hostname``/etc/hosts`。但它在容器外部看不到,既不会在 `docker ps` 中显示,也不会在其他的容器的 `/etc/hosts` 看到。
--dns=IP_ADDRESS
添加dns服务器到容器的/etc/resolv,conf中让容器用这ip地址来解析所有不在/etc/hosts中的主机名
`--link=CONTAINER_NAME:ALIAS`
选项会在创建容器的时候,添加一个其他容器的主机名到 `/etc/hosts` 文件中,让新容器的进程可以使用主机名 ALIAS 就可以连接它
--dns-search=DOMAIN
设定容器的搜索域,当设定搜索域为.example.com时会在搜索一个host主机名时dns不仅搜索host还会搜索host.example.com
注意如果没有上述最后2个选项docker会用主机上的/etc/resolv.conf来配置容器它是默认配置。
`--dns=IP_ADDRESS`
添加 DNS 服务器到容器的 `/etc/resolv.conf` 中,让容器用这个服务器来解析所有不在 `/etc/hosts` 中的主机名。
`--dns-search=DOMAIN`
设定容器的搜索域,当设定搜索域为 `.example.com` 时,在搜索一个名为 host 的主机时DNS 不仅搜索host还会搜索 `host.example.com`
注意:如果没有上述最后 2 个选项Docker 会默认用主机上的 `/etc/resolv.conf` 来配置容器。

View File

@@ -1,19 +1,22 @@
##定制docker0
docker服务默认会创建一个docker0接口它在linux内核层桥接所有物理或虚拟网卡,这就将所有容器和主机接口都放到同一个物理网络。
Docker指定了docker0的ip地址和子网掩码让主机和容器之间可以通过网桥相互通信它还给出了MTU-接口允许接收的最大传输单元通常是1500bytes或宿主主机网络路由上支持的默认值这2个都需要在服务启动的时候配置。
* --bip=CIDR — 192.168.1.5/24.ip地址加掩码 使用这种格式
* --mtu=BYTES — 覆盖默认的docker mtu配置
## 配置 docker0 网桥
Docker 服务默认会创建一个 `docker0` 网桥(其上有一个 `docker0` 内部接口,它在内核层连通了其他的物理或虚拟网卡,这就将所有容器和本地主机都放到同一个物理网络。
你可以在配置文件中配置DOCKER_OPTS然后重启来改变这些参数
Docker 默认指定了 `docker0` 接口 的 IP 地址和子网掩码,让主机和容器之间可以通过网桥相互通信,它还给出了 MTU接口允许接收的最大传输单元通常是 1500 Bytes或宿主主机网络路由上支持的默认值。这些值都可以在服务启动的时候进行配置
* `--bip=CIDR` -- IP 地址加掩码格式,例如 192.168.1.5/24
* `--mtu=BYTES` -- 覆盖默认的 Docker mtu 配置
也可以在配置文件中配置 DOCKER_OPTS然后重启服务。
由于目前 Docker 网桥是 Linux 网桥,用户可以使用 `brctl show` 来查看网桥和端口连接信息。
```
# 当容器启动后你可以使用brctl来确认他们是否已经连接到docker0网桥
$ sudo brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.3a1d7362b4ee no veth65f9
vethdda6
```
如果brctl命令没安装的话在ubuntu中可以使用apt-get install bridge-utils这个命令来安装
docker0 网桥设置会在每次创建新容器的时候被使用。docker从可用的地址段中选择一个空闲的ip地址给容器的eth0端口子网掩码使用网桥docker0的配置docker主机本身的ip作为容器的网关使用。
```
*注:`brctl` 命令在 Debian、Ubuntu 中可以使用 `sudo apt-get install bridge-utils` 来安装
每次创建一个新容器的时候Docker 从可用的地址段中选择一个空闲的 IP 地址分配给容器的 eth0 端口。使用本地主机上 `docker0` 接口的 IP 作为所有容器的默认网关。
```
$ sudo docker run -i -t --rm base /bin/bash
$ ip addr show eth0
@@ -28,4 +31,3 @@ default via 172.17.42.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.3
$ exit
```
转发数据包需要在主机上设定ip_forward参数为1,上文介绍过。

View File

@@ -1,8 +1,8 @@
##工具和示例
## 工具和示例
在介绍自定义网络拓扑之前,你可能会对一些外部工具和例子感兴趣:
https://github.com/jpetazzo/pipework
Jérôme Petazzoni 创建了一个叫pipework的shell脚本来帮助我们在复杂的场景中完成网络连接
https://github.com/brandon-rhodes/fopnp/tree/m/playground
Brandon Rhodes创建了一个完整的docker容器网络拓扑包含 nat 防火墙服务包括HTTP, SMTP, POP, IMAP, Telnet, SSH, and FTP:
工具使用的网络命令跟我们之前看到非常相似。
### pipework
Jérôme Petazzoni 编写了一个叫 [pipework](https://github.com/jpetazzo/pipework) 的 shell 脚本,可以帮助用户在比较复杂的场景中完成容器的连接。
### playground
Brandon Rhodes 创建了一个提供完整的 Docker 容器网络拓扑管理的 [Python库](https://github.com/brandon-rhodes/fopnp/tree/m/playground)包括路由、NAT 防火墙;以及一些提供 HTTP, SMTP, POP, IMAP, Telnet, SSH, FTP 的服务器。

View File

@@ -1,23 +0,0 @@
##快速配置指南
下面是一个跟docker网络相关的命令列表希望可以让你快速找到需要的信息。有些命令选项只有在docker服务启动的时候才可以执行而且不能马上生效。
* -b BRIDGE or --bridge=BRIDGE — 桥接配置
* --bip=CIDR — 定制docker0的掩码
* -H SOCKET... or --host=SOCKET... — 它告诉docker从哪个通道来接收run container stop
container这样的命令也是docker api的地址
* --icc=true|false — 请看下文容器之间的通信
* --ip-forward=true|false — 请看下文容器之间的通信
* --iptables=true|false — 请看下文容器之间的通信
* --mtu=BYTES —请看下文定制docker0
下面2个可以在docker服务启动和docker run执行的时候指定服务启动的时候指定则会为docker run设定默认值docker run 后面指定可以覆盖默认值。
* --dns=IP_ADDRESS... — 请看下文dns配置
* --dns-search=DOMAIN... — 请看下文dns配置
最后这些选项只有在docker run后执行因为它是针对容器的特性内容。
*-h HOSTNAME or --hostname=HOSTNAME — 主机名配置
*--link=CONTAINER_NAME:ALIAS — link系统
*--net=bridge|none|container:NAME_or_ID|host —桥接配置
*-p SPEC or --publish=SPEC — 映射容器端口到宿主主机
* -P or --publish-all=true|false — 映射容器端口到宿主主机

View File

@@ -1,60 +1 @@
##Docker 如何连接到容器?
让我们回顾一些基础知识:
机器需要一个网络接口来发送和接受数据包路由表来定义如何到达哪些地址段。这里的网络接口可以不是物理接口。事实上每个linxu机器上的lo环回接口docker 容器中也有就是一个完全的linux内核虚拟接口它直接复制发送缓存中的数据包到接收缓存中。docker让宿主主机和容器使用特殊的虚拟接口来通信--通信的2端叫“peers“他们在主机内核中连接在一起所以能够相互通信。创建他们很简单前面介绍过了。
docker创建容器的步骤如下
* 创建一对虚拟接口
* 其中宿主主机一端使用一个名字比如veth65f9他是唯一的,另外一端桥接到默认的docker0,或其它你指定的桥接网卡。
* 主机上的veth65f9这种接口映射到新的新容器中的名称通常是eth0,在容器这个隔离的network namespace
中,它是唯一的,不会有其他接口名字和它冲突。
* 从主机桥接网卡的地址段中获取一个空闲地址给eth0使用并设定默认路由到桥接网卡。
* 完成这些之后容器就可以使用这eth0虚拟网卡来连接其他容器和其他网络。
你也可以为特殊的容器设定特定的参数在docker run的时候使用--net它有4个可选参数
* --net=bridge — .默认连接到docker0网桥。
* --net=host — 告诉docker不要将容器放到隔离的网络堆栈中。从本质上讲这个选项告诉docker
不要容器化容器的网络尽管容器还是有自己的文件系统、进程列表和资源限制。但使用ip addr命令这样命令就可以知道实际上此时的的容器处于和docker 宿主主机的一样的网络级别,它拥有完全的宿主主机接口访问权限。虽然它不允许容器重新配置主机的网络堆栈,除非--privileged=true — 但是容器进程可以跟其他root进程一样可以打开低数字的端口可以访问本地网络服务比如D-bus还可以让容器做一些意想不到的事情比如重启主机使用这个选项的时候要非常小心
* --net=container:NAME_or_ID —
告诉docker将新容器的进程放到一个已经存在的容器的网络堆栈中新容器进程有它自己的文件系统、进程列表和资源限制但它会和那个已经存在的容器共享ip地址和端口他们之间来可以通过环回接口通信。
* --net=none — 告诉docker将新容器放到自己的网络堆栈中但是不要配置它的网络,
类似于vmware的host-only。这可以让你创建任何自定义的配置本文最后一段将介绍 他们。
下面通过配置一个以--net=none启动的容器使他达到跟平常一样具有访问网络的权限。来介绍docker是如何连接到容器中的。
启动一个/bin/bash 指定--net=none
```
$ sudo docker run -i -t --rm --net=none base /bin/bash
root@63f36fc01b5f:/#
```
再开启一个新的终端查找这个容器的进程id然后创建它的命名空间后面的ip netns会用到
```$ sudo docker inspect -f '{{.State.Pid}}' 63f36fc01b5f
2778
$ pid=2778
$ sudo mkdir -p /var/run/netns
$ sudo ln -s /proc/$pid/ns/net /var/run/netns/$pid
```
检查桥接网卡的ip和子网掩码
```
$ ip addr show docker0
21: docker0: ...
inet 172.17.42.1/16 scope global docker0
...
```
创建一对”peer“接口A和B绑定A到网桥并启用它
```
$ sudo ip link add A type veth peer name B
$ sudo brctl addif docker0 A
$ sudo ip link set A up
```
将B放到容器的网络命名空间命名为eth0,配置一个空闲的ip
```
$ sudo ip link set B netns $pid
$ sudo ip netns exec $pid ip link set dev B name eth0
$ sudo ip netns exec $pid ip link set eth0 up
$ sudo ip netns exec $pid ip addr add 172.17.42.99/16 dev eth0
$ sudo ip netns exec $pid ip route add default via 172.17.42.1
```
自此,你又可以像平常一样使用网络了
当你退出shell后docker清空容器容器的eth0随网络命名空间一起被摧毁A 接口也被自动从docker0取消注册。不用其他命令所有东西都被清理掉了
注意ip netns exec命令它可以让我们像root一样配置网络命名空间。但在容器内部无法使用因为统一的安全策略docker限制容器进程配置自己的网络。使用ip netns exec 可以让我们不用设置--privileged=true就可以完成一些可能带来危险的操作。

View File

@@ -1,37 +1,43 @@
##映射一个容器端口到宿主主机
## 映射容器端口到宿主主机的实现
默认情况下,容器可以建立到外部网络的连接,但是外部网络无法连接到容器。所有到外部的连接源地址都会被伪装成宿主主机的ip地址iptables的 masquerading来做到这一点。
默认情况下,容器可以主动访问到外部网络的连接,但是外部网络无法访问到容器。
### 容器访问外部实现
容器所有到外部网络的连接源地址都会被NAT成本地系统的IP地址。这是使用 `iptables` 的源地址伪装操作实现的。
查看主机的 NAT 规则。
```
# 查看主机的masquerading规则
$ sudo iptables -t nat -L -n
$ sudo iptables -t nat -nL
...
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 172.17.0.0/16 !172.17.0.0/16
...
```
其中,上述规则将所有源地址在 `172.17.0.0/16` 网段目标地址为其他网段外部网络的流量动态伪装为从系统网卡发出。MASQUERADE 跟传统 SNAT 的好处是它能动态从网卡获取地址。
当你希望容器接收外部连接时你需要在docker run执行的时候就指定对应选项第五章详细介绍了2种方法
* 指定-P --publish-all=true|false 选项会映射dockerfile
中expose的所有端口主机端口在49000-49900中随机挑选。当你的另外一个容器需要学习这个端口时候很不方便。
* 指定-p SPEC或则 --publish=SPEC,可以指定任意端口从主机映射容器内部
### 外部访问容器实现
不管用那种办法你可以通过查看iptable的 nat表来观察docker 在网络层做了什么操作
容器允许外部访问,可以在 `docker run` 时候通过 `-p``-P` 参数来启用
不管用那种办法,其实也是在本地的 `iptable` 的 nat 表中添加相应的规则。
使用 `-P` 时:
```
#使用-P时
$ iptables -t nat -L -n
$ iptables -t nat -nL
...
Chain DOCKER (2 references)
target prot opt source destination
DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:49153 to:172.17.0.2:80
#使用-p 80:80时
$ iptables -t nat -L -n
```
使用 `-p 80:80` 时:
```
$ iptables -t nat -nL
Chain DOCKER (2 references)
target prot opt source destination
DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:172.17.0.2:80
```
注意:
* 这里看到docker映射了0.0.0.0.它接受主机上的所有接口地址。可以通过-p IP:host_port:container_port 或则 -p
IP::port 来指定主机上的ip、接口制定更严格的规则。
* 如果希望永久改变绑定的主机ip地址可以 在dcoker 配置中指定--ip=IP_ADDRESS. 记得重启服务
* 这里的规则映射了 0.0.0.0,意味着将接受主机来自所有接口的流量。用户可以通过 `-p IP:host_port:container_port` 或 `-p
IP::port` 来指定允许访问容器的主机上的 IP、接口等制定更严格的规则。
* 如果希望永久绑定到某个固定的 IP 地址,可以在 Docker 配置文件 `/etc/default/docker` 中指定 `DOCKER_OPTS="--ip=IP_ADDRESS"`,之后重启 Docker 服务即可生效。

View File

@@ -1,15 +1,19 @@
##创建一个点到点连接
默认docker会将所有容器连接到由docker0提供的虚拟子网你也可以使用自己创建的网桥。但如果你想要2个特殊的容器之间可以直连通信而不用去配置复杂的主机网卡桥接
解决办法很简单创建一对接口把2个容器放到这对接口中配置成点到点链路类型。这2个容器就可以直接通信了。配置如下
## 示例:创建一个点到点连接
默认情况下Docker 会将所有容器连接到由 `docker0` 提供的虚拟子网
用户有时候需要两个容器之间可以直连通信,而不用通过主机网桥进行桥接。
解决办法很简单:创建一对 `peer` 接口,分别放到两个容器中,配置成点到点链路类型即可。
首先启动 2 个容器:
```
# 在2个终端中启动2个容器
$ sudo docker run -i -t --rm --net=none base /bin/bash
root@1f1f4c1f931a:/#
$ sudo docker run -i -t --rm --net=none base /bin/bash
root@12e343489d2f:/#
```
找到他们的process IDs ,然后创建他们的 namespace entries
找到进程号,然后创建网络名字空间的跟踪文件。
```
$ sudo docker inspect -f '{{.State.Pid}}' 1f1f4c1f931a
2989
@@ -20,7 +24,7 @@ $ sudo ln -s /proc/2989/ns/net /var/run/netns/2989
$ sudo ln -s /proc/3004/ns/net /var/run/netns/3004
```
创建"peer"接口,然后配置路由
创建一对 `peer` 接口,然后配置路由
```
$ sudo ip link add A type veth peer name B
@@ -34,7 +38,8 @@ $ sudo ip netns exec 3004 ip addr add 10.1.1.2/32 dev B
$ sudo ip netns exec 3004 ip link set B up
$ sudo ip netns exec 3004 ip route add 10.1.1.1/32 dev B
```
现在这2个容器就可以相互ping通并成功建立连接。点到点链路不需要子网和子网掩码使用ip route 来连接单个ip地址到指定的网络接口
如果没有特殊需要你不需要指定--net=none来创建点到点链路。
现在这 2 个容器就可以相互 ping 通,并成功建立连接。点到点链路不需要子网和子网掩码。
还有一个办法就是创建一个只跟主机通信的容器,除非有特殊需求,你可以仅用--icc=false来限制主机间的通信。
此外,也可以不指定 `--net=none` 来创建点到点链路。这样容器还可以通过原先的网络来通信。
利用类似的办法,可以创建一个只跟主机通信的容器。但是一般情况下,更推荐使用 `--icc=false` 来关闭容器之间的通信。

View File

@@ -0,0 +1,23 @@
## 快速配置指南
下面是一个跟 Docker 网络相关的命令列表。
其中有些命令选项只有在 Docker 服务启动的时候才能配置,而且不能马上生效。
* `-b BRIDGE or --bridge=BRIDGE` --指定容器挂载的网桥
* `--bip=CIDR` --定制 docker0 的掩码
* `-H SOCKET... or --host=SOCKET...` --Docker 服务端接收命令的通道
* `--icc=true|false` --是否支持容器之间进行通信
* `--ip-forward=true|false` --请看下文容器之间的通信
* `--iptables=true|false` --禁止 Docker 添加 iptables 规则
* `--mtu=BYTES` --容器网络中的 MTU
下面2个命令选项既可以在启动服务时指定也可以 Docker 容器启动(`docker run`)时候指定。在 Docker 服务启动的时候指定则会成为默认值,后面执行 `docker run` 时可以覆盖设置的默认值。
* `--dns=IP_ADDRESS...` --使用指定的DNS服务器
* `--dns-search=DOMAIN...` --指定DNS搜索域
最后这些选项只有在 `docker run` 执行时使用,因为它是针对容器的特性内容。
* `-h HOSTNAME or --hostname=HOSTNAME` --配置容器主机名
* `--link=CONTAINER_NAME:ALIAS` --添加到另一个容器的连接
* `--net=bridge|none|container:NAME_or_ID|host` --配置容器的桥接模式
* `-p SPEC or --publish=SPEC` --映射容器端口到宿主主机
* `-P or --publish-all=true|false` --映射容器所有端口到宿主主机

168
appendix_command/README.md Normal file
View File

@@ -0,0 +1,168 @@
# Docker命令查询
##基本语法
docker [OPTIONS] COMMAND [arg...]
一般来说Docker 命令可以用来管理 daemon或者通过 CLI 命令管理镜像和容器。可以通过 `man docker` 来查看这些命令。
##选项
-D=true|false
使用 debug 模式。默认为 false。
-H, --host=[unix:///var/run/docker.sock]: tcp://[host:port]来绑定或者 unix://[/path/to/socket] 来使用。
在 daemon 模式下绑定的 socket通过一个或多个 tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd 来指定。
--api-enable-cors=true|false
在远端 API 中启用 CORS 头。缺省为 false。
-b=""
将容器挂载到一个已存在的网桥上。指定为 'none' 时则禁用容器的网络。
--bip=""
让动态创建的 docker0 采用给定的 CIDR 地址; 与 -b 选项互斥。
-d=true|false
使用 daemon 模式。缺省为 false。
--dns=""
让 Docker 使用给定的 DNS 服务器。
-g=""
指定 Docker 运行时的 root 路径。缺省为 /var/lib/docker。
--icc=true|false
启用容器间通信。默认为 true。
--ip=""
绑定端口时候的默认 IP 地址。缺省为 0.0.0.0。
--iptables=true|false
禁止 Docker 添加 iptables 规则。缺省为 true。
--mtu=VALUE
指定容器网络的 mtu。缺省为 1500。
-p=""
指定 daemon 的 PID 文件路径。缺省为 /var/run/docker.pid。
-s=""
强制 Docker 运行时使用给定的存储驱动。
-v=true|false
输出版本信息并退出。缺省值为 false。
--selinux-enabled=true|false
启用 SELinux 支持。缺省值为 false。SELinux 目前不支持 BTRFS 存储驱动。
##命令
Docker 的命令可以采用 `docker-CMD` 或者 `docker CMD` 的方式执行。两者一致。
docker-attach(1)
依附到一个正在运行的容器中。
docker-build(1)
从一个 Dockerfile 创建一个镜像
docker-commit(1)
从一个容器的修改中创建一个新的镜像
docker-cp(1)
从容器中复制文件到宿主系统中
docker-diff(1)
检查一个容器文件系统的修改
docker-events(1)
从服务端获取实时的事件
docker-export(1)
导出容器内容为一个 tar 包
docker-history(1)
显示一个镜像的历史
docker-images(1)
列出存在的镜像
docker-import(1)
导入一个文件(典型为 tar 包)路径或目录来创建一个镜像
docker-info(1)
显示一些相关的系统信息
docker-inspect(1)
显示一个容器的底层具体信息。
docker-kill(1)
关闭一个运行中的容器 (包括进程和所有资源)
docker-load(1)
从一个 tar 包中加载一个镜像
docker-login(1)
注册或登录到一个 Docker 的仓库服务器
docker-logout(1)
从 Docker 的仓库服务器登出
docker-logs(1)
获取容器的 log 信息
docker-pause(1)
暂停一个容器中的所有进程
docker-port(1)
查找一个 nat 到一个私有网口的公共口
docker-ps(1)
列出容器
docker-pull(1)
从一个Docker的仓库服务器下拉一个镜像或仓库
docker-push(1)
将一个镜像或者仓库推送到一个 Docker 的注册服务器
docker-restart(1)
重启一个运行中的容器
docker-rm(1)
删除给定的若干个容器
docker-rmi(1)
删除给定的若干个镜像
docker-run(1)
创建一个新容器,并在其中运行给定命令
docker-save(1)
保存一个镜像为 tar 包文件
docker-search(1)
在 Docker index 中搜索一个镜像
docker-start(1)
启动一个容器
docker-stop(1)
终止一个运行中的容器
docker-tag(1)
为一个镜像打标签
docker-top(1)
查看一个容器中的正在运行的进程信息
docker-unpause(1)
将一个容器内所有的进程从暂停状态中恢复
docker-version(1)
输出 Docker 的版本信息
docker-wait(1)
阻塞直到一个容器终止,然后输出它的退出符
##一张图总结 Docker 的命令
![命令周期](../_images/cmd_logic.png)

2
appendix_repo/README.md Normal file
View File

@@ -0,0 +1,2 @@
# 常见仓库介绍
本章将介绍常见的一些仓库和镜像的功能,使用方法和生成它们的 Dockerfile 等。包括 Ubuntu、CentOS、MySQL、MongoDB、Redis、Nginx、Wordpress、Node.js 等。

17
appendix_repo/centos.md Normal file
View File

@@ -0,0 +1,17 @@
## [CentOS](https://registry.hub.docker.com/_/centos/)
### 基本信息
[CentOS](https://en.wikipedia.org/wiki/CentOS) 是流行的 Linux 发行版,其软件包大多跟 RedHat 系列保持一致。
该仓库提供了 CentOS 从 5 ~ 7 各个版本的镜像。
### 使用方法
默认会启动一个最小化的 CentOS 环境。
```
$ sudo docker run --name some-centos -i -t centos bash
bash-4.2#
```
### Dockerfile
* [CentOS 5 版本](https://github.com/CentOS/sig-cloud-instance-images/blob/2e5a9c4e8b7191b393822e4b9e98820db5638a77/docker/Dockerfile)
* [CentOS 6 版本](https://github.com/CentOS/sig-cloud-instance-images/blob/8717e33ea5432ecb33d7ecefe8452a973715d037/docker/Dockerfile)
* [CentOS 7 版本](https://github.com/CentOS/sig-cloud-instance-images/blob/af7a1b9f8f30744360a10fe44c53a1591bef26f9/docker/Dockerfile)

26
appendix_repo/mongodb.md Normal file
View File

@@ -0,0 +1,26 @@
## [MongoDB](https://registry.hub.docker.com/_/mongo/)
### 基本信息
[MongoDB](https://en.wikipedia.org/wiki/MongoDB) 是开源的 NoSQL 数据库实现。
该仓库提供了 MongoDB 2.2 ~ 2.7 各个版本的镜像。
### 使用方法
默认会在 `27017` 端口启动数据库。
```
$ sudo docker run --name some-mongo -d mongo
```
使用其他应用连接到容器,可以用
```
$ sudo docker run --name some-app --link some-mongo:mongo -d application-that-uses-mongo
```
或者通过 `mongo`
```
$ sudo docker run -it --link some-mongo:mongo --rm mongo sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'
```
### Dockerfile
* [2.2 版本](https://github.com/docker-library/mongo/blob/77c841472ccb6cc87fea1218269d097405edc6cb/2.2/Dockerfile)
* [2.4 版本](https://github.com/docker-library/mongo/blob/807078cb7b5f0289f6dabf9f6875d5318122bc30/2.4/Dockerfile)
* [2.6 版本](https://github.com/docker-library/mongo/blob/77c841472ccb6cc87fea1218269d097405edc6cb/2.6/Dockerfile)
* [2.7 版本](https://github.com/docker-library/mongo/blob/807078cb7b5f0289f6dabf9f6875d5318122bc30/2.7/Dockerfile)

23
appendix_repo/mysql.md Normal file
View File

@@ -0,0 +1,23 @@
## [MySQL](https://registry.hub.docker.com/_/mysql/)
### 基本信息
[MySQL](https://en.wikipedia.org/wiki/MySQL) 是开源的关系数据库实现。
该仓库提供了 MySQL 各个版本的镜像,包括 5.6 系列、5.7 系列等。
### 使用方法
默认会在 `3306` 端口启动数据库。
```
$ sudo docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql
```
之后就可以使用其它应用来连接到该容器。
```
$ sudo docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql
```
或者通过 `mysql`
```
$ sudo docker run -it --link some-mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
```
### Dockerfile
* [5.6 版本](https://github.com/docker-library/mysql/blob/7461a52b43f06839a4d8723ae8841f4cb616b3d0/5.6/Dockerfile)
* [5.7 版本](https://github.com/docker-library/mysql/blob/7461a52b43f06839a4d8723ae8841f4cb616b3d0/5.7/Dockerfile)

34
appendix_repo/nginx.md Normal file
View File

@@ -0,0 +1,34 @@
## [Nginx](https://registry.hub.docker.com/_/nginx/)
### 基本信息
[Nginx](https://en.wikipedia.org/wiki/Nginx) 是开源的高效的 Web 服务器实现,支持 HTTP、HTTPS、SMTP、POP3、IMAP 等协议。
该仓库提供了 Nginx 1.0 ~ 1.7 各个版本的镜像。
### 使用方法
下面的命令将作为一个静态页面服务器启动。
```
$ sudo docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
```
用户也可以不使用这种映射方式,通过利用 Dockerfile 来直接将静态页面内容放到镜像中,内容为
```
FROM nginx
COPY static-html-directory /usr/share/nginx/html
```
之后生成新的镜像,并启动一个容器。
```
$ sudo docker build -t some-content-nginx .
$ sudo docker run --name some-nginx -d some-content-nginx
```
开放端口,并映射到本地的 `8080` 端口。
```
sudo docker run --name some-nginx -d -p 8080:80 some-content-nginx
```
Nginx的默认配置文件路径为 `/etc/nginx/nginx.conf`,可以通过映射它来使用本地的配置文件,例如
```
docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
```
使用配置文件时,为了在容器中正常运行,需要保持 `daemon off;`
### Dockerfile
* [1 ~ 1.7 版本](https://github.com/nginxinc/docker-nginx/blob/3713a0157083eb4776e71f5a5aef4b2a5bc03ab1/Dockerfile)

28
appendix_repo/nodejs.md Normal file
View File

@@ -0,0 +1,28 @@
## [Node.js](https://registry.hub.docker.com/_/node/)
### 基本信息
[Node.js](https://en.wikipedia.org/wiki/Node.js)是基于 JavaScript 的可扩展服务端和网络软件开发平台。
该仓库提供了 Node.js 0.8 ~ 0.11 各个版本的镜像。
### 使用方法
在项目中创建一个 Dockerfile。
```
FROM node:0.10-onbuild
# replace this with your application's default port
EXPOSE 8888
```
然后创建镜像,并启动容器
```
$ sudo docker build -t my-nodejs-app
$ sudo docker run -it --rm --name my-running-app my-nodejs-app
```
也可以直接运行一个简单容器。
```
$ sudo docker run -it --rm --name my-running-script -v "$(pwd)":/usr/src/myapp -w /usr/src/myapp node:0.10 node your-daemon-or-script.js
```
### Dockerfile
* [0.8 版本](https://github.com/docker-library/node/blob/d017d679e92e84a810c580cdb29fcdbba23c2bb9/0.8/Dockerfile)
* [0.10 版本](https://github.com/docker-library/node/blob/913a225f2fda34d6a811fac1466e4f09f075fcf6/0.10/Dockerfile)
* [0.11 版本](https://github.com/docker-library/node/blob/d017d679e92e84a810c580cdb29fcdbba23c2bb9/0.11/Dockerfile)

29
appendix_repo/redis.md Normal file
View File

@@ -0,0 +1,29 @@
## [Redis](https://registry.hub.docker.com/_/redis/)
### 基本信息
[Redis](https://en.wikipedia.org/wiki/Redis) 是开源的内存 Key-Value 数据库实现。
该仓库提供了 Redis 2.6 ~ 2.8.9 各个版本的镜像。
### 使用方法
默认会在 `6379` 端口启动数据库。
```
$ sudo docker run --name some-redis -d redis
```
另外还可以启用 [持久存储](http://redis.io/topics/persistence)。
```
$ sudo docker run --name some-redis -d redis redis-server --appendonly yes
```
默认数据存储位置在 `VOLUME/data`。可以使用 `--volumes-from some-volume-container``-v /docker/host/dir:/data` 将数据存放到本地。
使用其他应用连接到容器,可以用
```
$ sudo docker run --name some-app --link some-redis:redis -d application-that-uses-redis
```
或者通过 `redis-cli`
```
$ sudo docker run -it --link some-redis:redis --rm redis sh -c 'exec redis-cli -h "$REDIS_PORT_6379_TCP_ADDR" -p "$REDIS_PORT_6379_TCP_PORT"'
```
### Dockerfile
* [2.6 版本](https://github.com/docker-library/redis/blob/02d9cd887a4e0d50db4bb085eab7235115a6fe4a/2.6.17/Dockerfile)
* [最新 2.8 版本](https://github.com/docker-library/redis/blob/d0665bb1bbddd4cc035dbc1fc774695fa534d648/2.8.13/Dockerfile)

17
appendix_repo/ubuntu.md Normal file
View File

@@ -0,0 +1,17 @@
## [Ubuntu](https://registry.hub.docker.com/_/ubuntu/)
### 基本信息
[Ubuntu](https://en.wikipedia.org/wiki/Ubuntu) 是流行的 Linux 发行版,其自带软件版本往往较新一些。
该仓库提供了 Ubuntu从12.04 ~ 14.10 各个版本的镜像。
### 使用方法
默认会启动一个最小化的 Ubuntu 环境。
```
$ sudo docker run --name some-ubuntu -i -t ubuntu
root@523c70904d54:/#
```
### Dockerfile
* [12.04 版本](https://github.com/tianon/docker-brew-ubuntu-core/blob/2b105575647a7e2030ff344d427c3920b89e17a9/precise/Dockerfile)
* [14.04 版本](https://github.com/tianon/docker-brew-ubuntu-core/blob/2b105575647a7e2030ff344d427c3920b89e17a9/trusty/Dockerfile)
* [14.10 版本](https://github.com/tianon/docker-brew-ubuntu-core/blob/2b105575647a7e2030ff344d427c3920b89e17a9/utopic/Dockerfile)

View File

@@ -0,0 +1,19 @@
## [WordPress](https://registry.hub.docker.com/_/wordpress/)
### 基本信息
[WordPress](https://en.wikipedia.org/wiki/WordPress) 是开源的 Blog 和内容管理系统框架,它基于 PhP 和 MySQL。
该仓库提供了 WordPress 4.0 版本的镜像。
### 使用方法
启动容器需要 MySQL 的支持,默认端口为 `80`
```
$ sudo docker run --name some-wordpress --link some-mysql:mysql -d wordpress
```
启动 WordPress 容器时可以指定的一些环境参数包括
* `-e WORDPRESS_DB_USER=...` 缺省为 “root”
* `-e WORDPRESS_DB_PASSWORD=...` 缺省为连接 mysql 容器的环境变量 `MYSQL_ROOT_PASSWORD` 的值
* `-e WORDPRESS_DB_NAME=...` 缺省为 “wordpress”
* `-e WORDPRESS_AUTH_KEY=...`, `-e WORDPRESS_SECURE_AUTH_KEY=...`, `-e WORDPRESS_LOGGED_IN_KEY=...`, `-e WORDPRESS_NONCE_KEY=...`, `-e WORDPRESS_AUTH_SALT=...`, `-e WORDPRESS_SECURE_AUTH_SALT=...`, `-e WORDPRESS_LOGGED_IN_SALT=...`, `-e WORDPRESS_NONCE_SALT=...` 缺省为随机 sha1 串
### Dockerfile
* [4.0 版本](https://github.com/docker-library/wordpress/blob/aee00669e7c43f435f021cb02871bffd63d5677a/Dockerfile)

View File

@@ -0,0 +1,7 @@
# 资源链接
* Docker 主站点: https://www.docker.io
* Docker 注册中心API: http://docs.docker.com/reference/api/registry_api/
* Docker Hub API: http://docs.docker.com/reference/api/docker-io_api/
* Docker 远端应用API: http://docs.docker.com/reference/api/docker_remote_api/
* Dockerfile 参考https://docs.docker.com/reference/builder/
* Dockerfile 最佳实践https://docs.docker.com/articles/dockerfile_best-practices/

View File

@@ -1,7 +0,0 @@
#架构
docker使用C/S架构docker daemon作为server端接受client的请求并处理创建、运行、分发容器他们可以运行在一个机器上也通过sockerts或者RESTful API通信。
![Docker基本架构](../images/docker_arch.png)
Docker daemon一般在宿主主机后台运行用户使用client而直接跟daemon交互。Docker client 以系统做bin命令的形式存在用户用docker命令来跟docker daemon交互。

View File

@@ -1,9 +0,0 @@
当我们运行`docker run -i -t ubuntu /bin/bash`命令时docker 在后台运行的操作如下:
* 如果本地有ubuntu这个image就从它创建容器否则从公有仓库下载
* 从image创建容器
* 分配一个文件系统并在只读的image层外面挂载一层可读写的层
* 从宿主主机配置的网桥接口中桥接一个虚拟接口到容器中去
* 从地址池配置一个ip地址给容器
* 执行你指定的程序,在这里启动一个/bin/bash进程
* -i -t 指定标准输入和输出

View File

@@ -1,3 +0,0 @@
每个docker都有很多层次构成docker使用 union file systems 将这些不同的层结合到一个image中去。
AUFS (AnotherUnionFS) 是一种 Union FS, 简单来说就是支持将不同目录挂载到同一个虚拟文件系统下(unite several directories into a single virtual filesystem)的文件系统, 更进一步的理解, AUFS支持为每一个成员目录(类似Git Branch)设定readonly、readwrite 和 whiteout-able 权限, 同时 AUFS 里有一个类似分层的概念, 对 readonly 权限的 branch 可以逻辑上进行修改(增量地, 不影响 readonly 部分的)。通常 Union FS 有两个用途, 一方面可以实现不借助 LVM、RAID 将多个disk挂到同一个目录下, 另一个更常用的就是将一个 readonly 的 branch 和一个 writeable 的 branch 联合在一起Live CD正是基于此方法可以允许在 OS image 不变的基础上允许用户在其上进行一些写操作。Docker 在 AUFS 上构建的 container image 也正是如此。

View File

@@ -1,13 +0,0 @@
docker有三个内部组件
* docker images
* docker registries
* docker containers
### Docker images
docker images 就是一个只读的模板。比如一个image可以包含一个ubuntu的操作系统里面安装了apache或者你需要的应用程序。images可以用来创建docker containersdocker提供了一个很简单的机制来创建images或者更新现有的images你甚至可以直接从其他人那里下载一个已经做好的images
###Docker registries
Docker registries 也叫docker 仓库它有公有仓库和私有仓库2种形式他们都可以用来让你上传和下载images。公有的仓库也叫 Docker Hub。它提供了一个巨大的image库可以让你下载你也可以在自己的局域网内建一个自己的私有仓库。
###Docker containers
Docker containers也叫docker容器容器是从image镜像创建的。它可以被启动、开始、停止、删除。每个容器都是相互隔离的、安全的平台。

View File

@@ -1 +0,0 @@
docker仓库用来保存我们的images当我们创建了自己的image之后我们就可以使用push命令将它上传到公有或者私有仓库这样下次要在另外一台机器上使用这个image时候只需要从仓库上pull下来就可以了。

View File

@@ -1,23 +0,0 @@
docker底层的2个核心技术分别是Namespaces和Control groups。
以下内容摘自InfoQ Docker自1.20版本开始docker已经抛开lxc不过下面的内容对于理解docker还是有很大帮助。
###pid namespace
不同用户的进程就是通过pid namespace隔离开的且不同 namespace 中可以有相同pid。所有的LXC进程在docker中的父进程为docker进程每个lxc进程具有不同的namespace。同时由于允许嵌套因此可以很方便的实现 Docker in Docker。
###net namespace
有了 pid namespace, 每个namespace中的pid能够相互隔离但是网络端口还是共享host的端口。网络隔离是通过net namespace实现的 每个net namespace有独立的 network devices, IP addresses, IP routing tables, /proc/net 目录。这样每个container的网络就能隔离开来。docker默认采用veth的方式将container中的虚拟网卡同host上的一个docker bridge: docker0连接在一起。
###ipc namespace
container中进程交互还是采用linux常见的进程间交互方法(interprocess communication - IPC), 包括常见的信号量、消息队列和共享内存。然而同 VM 不同的是container 的进程间交互实际上还是host上具有相同pid namespace中的进程间交互因此需要在IPC资源申请时加入namespace信息 - 每个IPC资源有一个唯一的 32 位 ID。
###mnt namespace
类似chroot将一个进程放到一个特定的目录执行。mnt namespace允许不同namespace的进程看到的文件结构不同这样每个 namespace 中的进程所看到的文件目录就被隔离开了。同chroot不同每个namespace中的container在/proc/mounts的信息只包含所在namespace的mount point。
###uts namespace
UTS("UNIX Time-sharing System") namespace允许每个container拥有独立的hostname和domain name, 使其在网络上可以被视作一个独立的节点而非Host上的一个进程。
###user namespace
每个container可以有不同的 user 和 group id, 也就是说可以在container内部用container内部的用户执行程序而非Host上的用户。
Control groups主要用来隔离各个容器和宿主主机的资源利用。

8
basic_concept/README.md Normal file
View File

@@ -0,0 +1,8 @@
# 基本概念
Docker 包括三个基本概念
* 镜像Image
* 容器Container
* 仓库Repository
理解了这三个概念,就理解了 Docker 的整个生命周期。

View File

@@ -0,0 +1,8 @@
## Docker 容器
Docker 利用容器来运行应用。
容器是从镜像创建的运行实例。它可以被启动、开始、停止、删除。每个容器都是相互隔离的、保证安全的平台。
可以把容器看做是一个简易版的 Linux 环境包括root用户权限、进程空间、用户空间和网络空间等和运行在其中的应用程序。
*注:镜像是只读的,容器在启动的时候创建一层可写层作为最上层。

8
basic_concept/image.md Normal file
View File

@@ -0,0 +1,8 @@
## Docker 镜像
Docker 镜像就是一个只读的模板。
例如:一个镜像可以包含一个完整的 ubuntu 操作系统环境,里面仅安装了 Apache 或用户需要的其它应用程序。
镜像可以用来创建 Docker 容器。
Docker 提供了一个很简单的机制来创建镜像或者更新现有的镜像,用户甚至可以直接从其他人那里下载一个已经做好的镜像来直接使用。

View File

@@ -0,0 +1,14 @@
## Docker 仓库
仓库是集中存放镜像文件的场所。有时候会把仓库和仓库注册服务器Registry混为一谈并不严格区分。实际上仓库注册服务器上往往存放着多个仓库每个仓库中又包含了多个镜像每个镜像有不同的标签tag
仓库分为公开仓库Public和私有仓库Private两种形式。
最大的公开仓库是 [Docker Hub](https://hub.docker.com),存放了数量庞大的镜像供用户下载。
国内的公开仓库包括 [Docker Pool](http://www.dockerpool.com) 等,可以提供大陆用户更稳定快速的访问。
当然,用户也可以在本地网络内创建一个私有仓库。
当用户创建了自己的镜像之后就可以使用 `push` 命令将它上传到公有或者私有仓库,这样下次在另外一台机器上使用这个镜像时候,只需要从仓库上 `pull` 下来就可以了。
*注Docker 仓库的概念跟 [Git](http://git-scm.com) 类似,注册服务器可以理解为 GitHub 这样的托管服务。

1
book.json Normal file
View File

@@ -0,0 +1 @@
{}

2
cases/README.md Normal file
View File

@@ -0,0 +1,2 @@
#实战案例
介绍一些典型的应用场景和案例。

View File

@@ -1,7 +1,7 @@
##多台物理主机之间的容器互联(暴露容器到真实网络中)
docker 默认的桥接网卡是docker0。它只会在本机桥接所有的容器网卡举例来说容器的虚拟网卡在主机上看一般叫做veth*** 而docker只是把所有这些网卡桥接在一起如下
## 多台物理主机之间的容器互联(暴露容器到真实网络中)
Docker 默认的桥接网卡是 docker0。它只会在本机桥接所有的容器网卡举例来说容器的虚拟网卡在主机上看一般叫做 veth*** 而 Docker 只是把所有这些网卡桥接在一起,如下:
```
[root@opnvz ~]# brctl show
[root@opnvz ~]# brctl show
bridge name bridge id STP enabled interfaces
docker0 8000.56847afe9799 no veth0889
veth3c7b
@@ -10,29 +10,30 @@ docker0 8000.56847afe9799 no veth0889
在容器中看到的地址一般是像下面这样的地址:
```
root@ac6474aeb31d:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
11: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 4a:7d:68:da:09:cf brd ff:ff:ff:ff:ff:ff
inet 172.17.0.3/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::487d:68ff:feda:9cf/64 scope link
inet6 fe80::487d:68ff:feda:9cf/64 scope link
valid_lft forever preferred_lft forever
```
这样就可以把这个网络看成是一个私有的网络通过nat 连接外网,如果要让外网连接到容器中,就需要做端口映射,即-p参数(更多原理参见本文第六小节)
如果在企业内部应用,或则做多个物理主机的集群,可能需要将多个物理主机的容器组到一个物理网络中来,那么就需要将这个网桥桥接到我们指定的网卡上。
这样就可以把这个网络看成是一个私有的网络,通过 nat 连接外网,如果要让外网连接到容器中,就需要做端口映射,即 -p 参数
###拓扑图
主机A和主机B的网卡一都连着物理交换机的同一个vlan 101,这样网桥一和网桥三就相当于在同一个物理网络中了而容器一、容器三、容器四也在同一物理网络中了他们之间可以相互通信而且可以跟同一vlan中的其他物理机器互联。
![物理拓扑图](../images/container_connect_topology.png)
如果在企业内部应用,或者做多个物理主机的集群,可能需要将多个物理主机的容器组到一个物理网络中来,那么就需要将这个网桥桥接到我们指定的网卡上。
###ubuntu示例
下面以ubuntu为例创建多个主机的容器联网:
创建自己的网桥,编辑/etc/network/interface文件
### 拓扑图
主机 A 和主机 B 的网卡一都连着物理交换机的同一个 vlan 101,这样网桥一和网桥三就相当于在同一个物理网络中了,而容器一、容器三、容器四也在同一物理网络中了,他们之间可以相互通信,而且可以跟同一 vlan 中的其他物理机器互联。
![物理拓扑图](../_images/container_connect_topology.png)
### ubuntu 示例
下面以 ubuntu 为例创建多个主机的容器联网:
创建自己的网桥,编辑 /etc/network/interface 文件
```
auto br0
iface br0 inet static
@@ -43,9 +44,9 @@ bridge_ports em1
bridge_stp off
dns-nameservers 8.8.8.8 192.168.6.1
```
docker的默认网桥绑定到这个新建的br0上面这样就将这台机器上容器绑定到em1这个网卡所对应的物理网络上了。
Docker 的默认网桥绑定到这个新建的 br0 上面,这样就将这台机器上容器绑定到 em1 这个网卡所对应的物理网络上了。
ubuntu修改/etc/default/docker文件 添加最后一行内容
ubuntu 修改 /etc/default/docker 文件添加最后一行内容
```
# Docker Upstart and SysVinit configuration file
@@ -63,15 +64,15 @@ ubuntu修改/etc/default/docker文件 添加最后一行内容
DOCKER_OPTS="-b=br0"
```
在启动docker的时候 使用-b参数 将容器绑定到物理网络上。重启docker服务后再进入容器可以看到它已经绑定到你的物理网络上了。
在启动 Docker 的时候 使用 -b 参数 将容器绑定到物理网络上。重启 Docker 服务后,再进入容器可以看到它已经绑定到你的物理网络上了。
```
root@ubuntudocker:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
58b043aa05eb desk_hz:v1 "/startup.sh" 5 days ago Up 2 seconds 5900/tcp, 6080/tcp, 22/tcp yanlx
58b043aa05eb desk_hz:v1 "/startup.sh" 5 days ago Up 2 seconds 5900/tcp, 6080/tcp, 22/tcp yanlx
root@ubuntudocker:~# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.7e6e617c8d53 no em1
vethe6e5
```
这样就直接把容器暴露到你的物理网络上了,多台物理主机的容器也可以相互联网了。需要注意的是,这样就需要自己来保证容器的网络安全了。
这样就直接把容器暴露到物理网络上了,多台物理主机的容器也可以相互联网了。需要注意的是,这样就需要自己来保证容器的网络安全了。

14
cases/environment.md Normal file
View File

@@ -0,0 +1,14 @@
## 标准化开发测试和生产环境
对于大部分企业来说,搭建 PaaS 既没有那个精力,也没那个必要,用 Docker 做个人的 sandbox 用处又小了点。
可以用 Docker 来标准化开发、测试、生产环境。
![企业应用结构](../_images/enterprise_usage.png)
Docker 占用资源小,在一台 E5 128 G 内存的服务器上部署 100 个容器都绰绰有余,可以单独抽一个容器或者直接在宿主物理主机上部署 samba利用 samba 的 home 分享方案将每个用户的 home 目录映射到开发中心和测试部门的 Windows 机器上。
针对某个项目组,由架构师搭建好一个标准的容器环境供项目组和测试部门使用,每个开发工程师可以拥有自己单独的容器,通过 `docker run -v` 将用户的 home 目录映射到容器中。需要提交测试时,只需要将代码移交给测试部门,然后分配一个容器使用 `-v` 加载测试部门的 home 目录启动即可。这样,在公司内部的开发、测试基本就统一了,不会出现开发部门提交的代码,测试部门部署不了的问题。
测试部门发布测试通过的报告后,架构师再一次检测容器环境,就可以直接交由部署工程师将代码和容器分别部署到生产环境中了。这种方式的部署横向性能的扩展性也极好。

66
cases/supervisor.md Normal file
View File

@@ -0,0 +1,66 @@
## 使用 Supervisor 来管理进程
Docker 容器在启动的时候开启单个进程,比如,一个 ssh 或者 apache 的 daemon 服务。但我们经常需要在一个机器上开启多个服务,这可以有很多方法,最简单的就是把多个启动命令放到一个启动脚本里面,启动的时候直接启动这个脚本,另外就是安装进程管理工具。
本小节将使用进程管理工具 supervisor 来管理容器中的多个进程。使用 Supervisor 可以更好的控制、管理、重启我们希望运行的进程。在这里我们演示一下如何同时使用 ssh 和 apache 服务。
### 配置
首先创建一个 Dockerfile内容和各部分的解释如下。
```
FROM ubuntu:13.04
MAINTAINER examples@docker.com
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
```
### 安装 ssh、apache 和 supervisor
```
RUN apt-get install -y --force-yes perl-base=5.14.2-6ubuntu2
RUN apt-get install -y apache2.2-common
RUN apt-get install -y openssh-server apache2 supervisor
RUN mkdir -p /var/run/sshd
RUN mkdir -p /var/log/supervisor
```
这里安装 3 个软件,还创建了 2 个 ssh 和 supervisor 服务正常运行所需要的目录。
```
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
```
添加 supervisord 的配置文件,并复制配置文件到对应目录下面。
```
EXPOSE 22 80
CMD ["/usr/bin/supervisord"]
```
这里我们映射了 22 和 80 端口,使用 supervisord 的可执行路径启动服务。
### supervisor配置文件内容
```
[supervisord]
nodaemon=true
[program:sshd]
command=/usr/sbin/sshd -D
[program:apache2]
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
```
配置文件包含目录和进程,第一段 supervsord 配置软件本身,使用 nodaemon 参数来运行。第二段包含要控制的 2 个服务。每一段包含一个服务的目录和启动这个服务的命令。
### 使用方法
创建镜像。
```
$ sudo docker build -t test/supervisord .
```
启动 supervisor 容器。
```
$ sudo docker run -p 22 -p 80 -t -i test/supervisord
2013-11-25 18:53:22,312 CRIT Supervisor running as root (no user in config file)
2013-11-25 18:53:22,312 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2013-11-25 18:53:22,342 INFO supervisord started with pid 1
2013-11-25 18:53:23,346 INFO spawned: 'sshd' with pid 6
2013-11-25 18:53:23,349 INFO spawned: 'apache2' with pid 7
```
使用 `docker run` 来启动我们创建的容器。使用多个 `-p` 来映射多个端口,这样我们就能同时访问 ssh 和 apache 服务了。
可以使用这个方法创建一个只有 ssh 服务的基础镜像,之后创建镜像可以使用这个镜像为基础来创建

85
cases/tomcat.md Normal file
View File

@@ -0,0 +1,85 @@
## 创建 tomcat/weblogic 集群
### 安装 tomcat 镜像
准备好需要的 jdk、tomcat 等软件放到 home 目录下面,启动一个容器
```
docker run -t -i -v /home:/opt/data --name mk_tomcat ubuntu /bin/bash
```
这条命令挂载本地 home 目录到容器的 /opt/data 目录,容器内目录若不存在,则会自动创建。接下来就是 tomcat 的基本配置jdk 环境变量设置好之后,将 tomcat 程序放到 /opt/apache-tomcat 下面
编辑 /etc/supervisor/conf.d/supervisor.conf 文件,添加 tomcat 项
```
[supervisord]
nodaemon=true
[program:tomcat]
command=/opt/apache-tomcat/bin/startup.sh
[program:sshd]
command=/usr/sbin/sshd -D
```
```
docker commit ac6474aeb31d tomcat
```
新建 tomcat 文件夹,新建 Dockerfile。
```
FROM mk_tomcat
EXPOSE 22 8080
CMD ["/usr/bin/supervisord"]
```
根据 Dockerfile 创建镜像。
```
docker build tomcat tomcat
```
### 安装 weblogic 镜像
步骤和 tomcat 基本一致,这里贴一下配置文件
```
supervisor.conf
[supervisord]
nodaemon=true
[program:weblogic]
command=/opt/Middleware/user_projects/domains/base_domain/bin/startWebLogic.sh
[program:sshd]
command=/usr/sbin/sshd -D
dockerfile
FROM weblogic
EXPOSE 22 7001
CMD ["/usr/bin/supervisord"]
```
### tomcat/weblogic 镜像的使用
#### 存储的使用
在启动的时候,使用 `-v` 参数
-v, --volume=[] Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)
将本地磁盘映射到容器内部,它在主机和容器之间是实时变化的,所以我们更新程序、上传代码只需要更新物理主机的目录就可以了
#### tomcat 和 weblogic 集群的实现
tomcat 只要开启多个容器即可
```
docker run -d -v -p 204:22 -p 7003:8080 -v /home/data:/opt/data --name tm1 tomcat /usr/bin/supervisord
docker run -d -v -p 205:22 -p 7004:8080 -v /home/data:/opt/data --name tm2 tomcat /usr/bin/supervisord
docker run -d -v -p 206:22 -p 7005:8080 -v /home/data:/opt/data --name tm3 tomcat /usr/bin/supervisord
```
这里说一下 weblogic 的配置,大家知道 weblogic 有一个域的概念。如果要使用常规的 administrator +node 的方式部署,就需要在 supervisord 中分别写出 administartor server 和 node server 的启动脚本,这样做的优点是:
* 可以使用 weblogic 的集群,同步等概念
* 部署一个集群应用程序,只需要安装一次应用到集群上即可
缺点是:
* Docker 配置复杂了
* 没办法自动扩展集群的计算容量,如需添加节点,需要在 administrator 上先创建节点,然后再配置新的容器 supervisor 启动脚本,然后再启动容器
另外种方法是将所有的程序都安装在 adminiserver 上面,需要扩展的时候,启动多个节点即可,它的优点和缺点和上一种方法恰恰相反。(建议使用这种方式来部署开发和测试环境)
```
docker run -d -v -p 204:22 -p 7001:7001 -v /home/data:/opt/data --name node1 weblogic /usr/bin/supervisord
docker run -d -v -p 205:22 -p 7002:7001 -v /home/data:/opt/data --name node2 weblogic /usr/bin/supervisord
docker run -d -v -p 206:22 -p 7003:7001 -v /home/data:/opt/data --name node3 weblogic /usr/bin/supervisord
```
这样在前端使用 nginx 来做负载均衡就可以完成配置了

4
compose/README.md Normal file
View File

@@ -0,0 +1,4 @@
# Docker Compose 项目
Docker Compose 是 Docker 官方编排Orchestration项目之一负责快速在集群中部署分布式应用。
本章将介绍 Compose 项目情况以及安装和使用。

142
compose/commands.md Normal file
View File

@@ -0,0 +1,142 @@
## Compose 命令说明
大部分命令都可以运行在一个或多个服务上。如果没有特别的说明,命令则应用在项目所有的服务上。
执行 `docker-compose [COMMAND] --help` 查看具体某个命令的使用说明。
基本的使用格式是
```sh
docker-compose [options] [COMMAND] [ARGS...]
```
## 选项
* `--verbose` 输出更多调试信息。
* `--version` 打印版本并退出。
* `-f, --file FILE` 使用特定的 compose 模板文件,默认为 `docker-compose.yml`
* `-p, --project-name NAME` 指定项目名称,默认使用目录名称。
## 命令
### `build`
构建或重新构建服务。
服务一旦构建后,将会带上一个标记名,例如 web_db。
可以随时在项目目录下运行 `docker-compose build` 来重新构建服务。
### `help`
获得一个命令的帮助。
### `kill`
通过发送 `SIGKILL` 信号来强制停止服务容器。支持通过参数来指定发送的信号,例如
```sh
$ docker-compose kill -s SIGINT
```
### `logs`
查看服务的输出。
### `port`
打印绑定的公共端口。
### `ps`
列出所有容器。
### `pull`
拉取服务镜像。
### `rm`
删除停止的服务容器。
### `run`
在一个服务上执行一个命令。
例如:
```
$ docker-compose run ubuntu ping docker.com
```
将会启动一个 ubuntu 服务,执行 `ping docker.com` 命令。
默认情况下,所有关联的服务将会自动被启动,除非这些服务已经在运行中。
该命令类似启动容器后运行指定的命令,相关卷、链接等等都将会按照期望创建。
两个不同点:
* 给定命令将会覆盖原有的自动运行命令;
* 不会自动创建端口,以避免冲突。
如果不希望自动启动关联的容器,可以使用 `--no-deps` 选项,例如
```
$ docker-compose run --no-deps web python manage.py shell
```
将不会启动 web 容器所关联的其它容器。
### `scale`
设置同一个服务运行的容器个数。
通过 `service=num` 的参数来设置数量。例如:
```
$ docker-compose scale web=2 worker=3
```
### `start`
启动一个已经存在的服务容器。
### `stop`
停止一个已经运行的容器,但不删除它。通过 `docker-compose start` 可以再次启动这些容器。
### `up`
构建,(重新)创建,启动,链接一个服务相关的容器。
链接的服务都将会启动,除非他们已经运行。
默认情况, `docker-compose up` 将会整合所有容器的输出,并且退出时,所有容器将会停止。
如果使用 `docker-compose up -d` ,将会在后台启动并运行所有的容器。
默认情况,如果该服务的容器已经存在, `docker-compose up` 将会停止并尝试重新创建他们(保持使用 `volumes-from` 挂载的卷),以保证 `docker-compose.yml` 的修改生效。如果你不想容器被停止并重新创建,可以使用 `docker-compose up --no-recreate`。如果需要的话,这样将会启动已经停止的容器。
## 环境变量
环境变量可以用来配置 Compose 的行为。
`DOCKER_`开头的变量和用来配置 Docker 命令行客户端的使用一样。如果使用 boot2docker , `$(boot2docker shellinit)` 将会设置它们为正确的值。
### `COMPOSE_PROJECT_NAME`
设置通过 Compose 启动的每一个容器前添加的项目名称,默认是当前工作目录的名字。
### `COMPOSE_FILE`
设置要使用的 `docker-compose.yml` 的路径。默认路径是当前工作目录。
### `DOCKER_HOST`
设置 Docker daemon 的地址。默认使用 `unix:///var/run/docker.sock`,与 Docker 客户端采用的默认值一致。
### `DOCKER_TLS_VERIFY`
如果设置不为空,则与 Docker daemon 交互通过 TLS 进行。
### `DOCKER_CERT_PATH`
配置 TLS 通信所需要的验证(`ca.pem``cert.pem``key.pem`)文件的路径,默认是 `~/.docker`

63
compose/install.md Normal file
View File

@@ -0,0 +1,63 @@
## 安装
安装 Compose 之前,要先安装 Docker在此不再赘述。
### PIP 安装
这种方式最为推荐。
执行命令。
```sh
$ sudo pip install -U docker-compose
```
安装成功后,可以查看 `docker-compose` 命令的用法。
```sh
$ docker-compose -h
Fast, isolated development environments using Docker.
Usage:
docker-compose [options] [COMMAND] [ARGS...]
docker-compose -h|--help
Options:
--verbose Show more output
--version Print version and exit
-f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name (default: directory name)
Commands:
build Build or rebuild services
help Get help on a command
kill Kill containers
logs View output from containers
port Print the public port for a port binding
ps List containers
pull Pulls service images
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
restart Restart services
up Create and start containers
```
之后,可以添加 bash 补全命令。
```sh
$ curl -L https://raw.githubusercontent.com/docker/compose/1.2.0/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
```
### 二进制包
发布的二进制包可以在 [https://github.com/docker/compose/releases](https://github.com/docker/compose/releases) 找到。
下载后直接放到执行路径即可。
例如,在常见的 Linux 平台上。
```
$ sudo curl -L https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ sudo chmod a+x /usr/local/bin/docker-compose
```

10
compose/intro.md Normal file
View File

@@ -0,0 +1,10 @@
## 简介
Compose 项目目前在 [Github](https://github.com/docker/compose) 上进行维护,目前最新版本是 1.2.0。
Compose 定位是“defining and running complex applications with Docker”前身是 Fig兼容 Fig 的模板文件。
Dockerfile 可以让用户管理一个单独的应用容器;而 Compose 则允许用户在一个模板YAML 格式)中定义一组相关联的应用容器(被称为一个 `project`,即项目),例如一个 Web 服务容器再加上后端的数据库服务容器等。
![](../_images/docker_compose.jpg)
该项目由 Python 编写,实际上调用了 Docker 提供的 API 来实现。

207
compose/usage.md Normal file
View File

@@ -0,0 +1,207 @@
## 使用
### 术语
首先介绍几个术语。
* 服务service一个应用容器实际上可以运行多个相同镜像的实例。
* 项目(project):由一组关联的应用容器组成的一个完整业务单元。
可见一个项目可以由多个服务容器关联而成Compose 面向项目进行管理。
### 场景
下面,我们创建一个经典的 Web 项目:一个 [Haproxy](www.haproxy.org),挂载三个 Web 容器。
创建一个 `compose-haproxy-web` 目录,作为项目工作目录,并在其中分别创建两个子目录:`haproxy``web`
### Web 子目录
这里用 Python 程序来提供一个简单的 HTTP 服务,打印出访问者的 IP 和 实际的本地 IP。
#### index.py
编写一个 `index.py` 作为服务器文件,代码为
```sh
#!/usr/bin/python
#authors: yeasy.github.com
#date: 2013-07-05
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import socket
import fcntl
import struct
import pickle
from datetime import datetime
from collections import OrderedDict
class HandlerClass(SimpleHTTPRequestHandler):
def get_ip_address(self,ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
def log_message(self, format, *args):
if len(args) < 3 or "200" not in args[1]:
return
try:
request = pickle.load(open("pickle_data.txt","r"))
except:
request=OrderedDict()
time_now = datetime.now()
ts = time_now.strftime('%Y-%m-%d %H:%M:%S')
server = self.get_ip_address('eth0')
host=self.address_string()
addr_pair = (host,server)
if addr_pair not in request:
request[addr_pair]=[1,ts]
else:
num = request[addr_pair][0]+1
del request[addr_pair]
request[addr_pair]=[num,ts]
file=open("index.html", "w")
file.write("<!DOCTYPE html> <html> <body><center><h1><font color=\"blue\" face=\"Georgia, Arial\" size=8><em>HA</em></font> Webpage Visit Results</h1></center>");
for pair in request:
if pair[0] == host:
guest = "LOCAL: "+pair[0]
else:
guest = pair[0]
if (time_now-datetime.strptime(request[pair][1],'%Y-%m-%d %H:%M:%S')).seconds < 3:
file.write("<p style=\"font-size:150%\" >#"+ str(request[pair][1]) +": <font color=\"red\">"+str(request[pair][0])+ "</font> requests " + "from &lt<font color=\"blue\">"+guest+"</font>&gt to WebServer &lt<font color=\"blue\">"+pair[1]+"</font>&gt</p>")
else:
file.write("<p style=\"font-size:150%\" >#"+ str(request[pair][1]) +": <font color=\"maroon\">"+str(request[pair][0])+ "</font> requests " + "from &lt<font color=\"navy\">"+guest+"</font>&gt to WebServer &lt<font color=\"navy\">"+pair[1]+"</font>&gt</p>")
file.write("</body> </html>");
file.close()
pickle.dump(request,open("pickle_data.txt","w"))
if __name__ == '__main__':
try:
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
addr = len(sys.argv) < 2 and "0.0.0.0" or sys.argv[1]
port = len(sys.argv) < 3 and 80 or int(sys.argv[2])
HandlerClass.protocol_version = Protocol
httpd = ServerClass((addr, port), HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
except:
exit()
```
#### index.html
生成一个临时的 `index.html` 文件,其内容会被 index.py 更新。
```sh
$ touch index.html
```
#### Dockerfile
生成一个 Dockerfile内容为
```sh
FROM python:2.7
WORKDIR /code
ADD . /code
EXPOSE 80
CMD python index.py
```
### haproxy 目录
在其中生成一个 `haproxy.cfg` 文件,内容为
```sh
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen stats :70
stats enable
stats uri /
frontend balancer
bind 0.0.0.0:80
mode http
default_backend web_backends
backend web_backends
mode http
option forwardfor
balance roundrobin
server weba weba:80 check
server webb webb:80 check
server webc webc:80 check
option httpchk GET /
http-check expect status 200
```
### docker-compose.yml
编写 docker-compose.yml 文件,这个是 Compose 使用的主模板文件。内容十分简单,指定 3 个 web 容器,以及 1 个 haproxy 容器。
```sh
weba:
build: ./web
expose:
- 80
webb:
build: ./web
expose:
- 80
webc:
build: ./web
expose:
- 80
haproxy:
image: haproxy:latest
volumes:
- ./haproxy:/haproxy-override
- ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
links:
- weba
- webb
- webc
ports:
- "80:80"
- "70:70"
expose:
- "80"
- "70"
```
### 运行 compose 项目
现在 compose-haproxy-web 目录长成下面的样子。
```sh
compose-haproxy-web
├── docker-compose.yml
├── haproxy
│ └── haproxy.cfg
└── web
├── Dockerfile
├── index.html
└── index.py
```
在该目录下执行 `docker-compose up` 命令,会整合输出所有容器的输出。
```
$sudo docker-compose up
Recreating composehaproxyweb_webb_1...
Recreating composehaproxyweb_webc_1...
Recreating composehaproxyweb_weba_1...
Recreating composehaproxyweb_haproxy_1...
Attaching to composehaproxyweb_webb_1, composehaproxyweb_webc_1, composehaproxyweb_weba_1, composehaproxyweb_haproxy_1
```
此时访问本地的 80 端口,会经过 haproxy 自动转发到后端的某个 web 容器上,刷新页面,可以观察到访问的容器地址的变化。
访问本地 70 端口,可以查看到 haproxy 的统计信息。
当然,还可以使用 consul、etcd 等实现服务发现,这样就可以避免手动指定后端的 web 容器了,更为灵活。

259
compose/yaml_file.md Normal file
View File

@@ -0,0 +1,259 @@
## YAML 模板文件
默认的模板文件是 `docker-compose.yml`,其中定义的每个服务都必须通过 `image` 指令指定镜像或 `build` 指令(需要 Dockerfile来自动构建。
其它大部分指令都跟 `docker run` 中的类似。
如果使用 `build` 指令,在 `Dockerfile` 中设置的选项(例如:`CMD`, `EXPOSE`, `VOLUME`, `ENV` 等) 将会自动被获取,无需在 `docker-compose.yml` 中再次设置。
### `image`
指定为镜像名称或镜像 ID。如果镜像在本地不存在`Compose` 将会尝试拉去这个镜像。
例如:
```sh
image: ubuntu
image: orchardup/postgresql
image: a4bc65fd
```
### `build`
指定 `Dockerfile` 所在文件夹的路径。 `Compose` 将会利用它自动构建这个镜像,然后使用这个镜像。
```
build: /path/to/build/dir
```
### `command`
覆盖容器启动后默认执行的命令。
```sh
command: bundle exec thin -p 3000
```
### `links`
链接到其它服务中的容器。使用服务名称(同时作为别名)或服务名称:服务别名 `SERVICE:ALIAS` 格式都可以。
```sh
links:
- db
- db:database
- redis
```
使用的别名将会自动在服务容器中的 `/etc/hosts` 里创建。例如:
```sh
172.17.2.186 db
172.17.2.186 database
172.17.2.187 redis
```
相应的环境变量也将被创建。
### `external_links`
链接到 docker-compose.yml 外部的容器,甚至 并非 `Compose` 管理的容器。参数格式跟 `links` 类似。
```
external_links:
- redis_1
- project_db_1:mysql
- project_db_1:postgresql
```
### `ports`
暴露端口信息。
使用宿主:容器 `HOST:CONTAINER`格式或者仅仅指定容器的端口(宿主将会随机选择端口)都可以。
```
ports:
- "3000"
- "8000:8000"
- "49100:22"
- "127.0.0.1:8001:8001"
```
*注:当使用 `HOST:CONTAINER` 格式来映射端口时,如果你使用的容器端口小于 60 你可能会得到错误得结果,因为 `YAML` 将会解析 `xx:yy` 这种数字格式为 60 进制。所以建议采用字符串格式。*
### `expose`
暴露端口,但不映射到宿主机,只被连接的服务访问。
仅可以指定内部端口为参数
```sh
expose:
- "3000"
- "8000"
```
### `volumes`
卷挂载路径设置。可以设置宿主机路径 `HOST:CONTAINER` 或加上访问模式 `HOST:CONTAINER:ro`)。
```sh
volumes:
- /var/lib/mysql
- cache/:/tmp/cache
- ~/configs:/etc/configs/:ro
```
### `volumes_from`
从另一个服务或容器挂载它的所有卷。
```sh
volumes_from:
- service_name
- container_name
```
### `environment`
设置环境变量。你可以使用数组或字典两种格式。
只给定名称的变量会自动获取它在 Compose 主机上的值,可以用来防止泄露不必要的数据。
```
environment:
RACK_ENV: development
SESSION_SECRET:
environment:
- RACK_ENV=development
- SESSION_SECRET
```
### `env_file`
从文件中获取环境变量,可以为单独的文件路径或列表。
如果通过 `docker-compose -f FILE` 指定了模板文件,则 `env_file` 中路径会基于模板文件路径。
如果有变量名称与 `environment` 指令冲突,则以后者为准。
```sh
env_file: .env
env_file:
- ./common.env
- ./apps/web.env
- /opt/secrets.env
```
环境变量文件中每一行必须符合格式,支持 `#` 开头的注释行。
```sh
# common.env: Set Rails/Rack environment
RACK_ENV=development
```
### `extends`
基于已有的服务进行扩展。例如我们已经有了一个 webapp 服务,模板文件为 `common.yml`
```sh
# common.yml
webapp:
build: ./webapp
environment:
- DEBUG=false
- SEND_EMAILS=false
```
编写一个新的 `development.yml` 文件,使用 `common.yml` 中的 webapp 服务进行扩展。
```sh
# development.yml
web:
extends:
file: common.yml
service: webapp
ports:
- "8000:8000"
links:
- db
environment:
- DEBUG=true
db:
image: postgres
```
后者会自动继承 common.yml 中的 webapp 服务及相关环节变量。
### `net`
设置网络模式。使用和 `docker client``--net` 参数一样的值。
```sh
net: "bridge"
net: "none"
net: "container:[name or id]"
net: "host"
```
### `pid`
跟主机系统共享进程命名空间。打开该选项的容器可以相互通过进程 ID 来访问和操作。
```sh
pid: "host"
```
### `dns`
配置 DNS 服务器。可以是一个值,也可以是一个列表。
```sh
dns: 8.8.8.8
dns:
- 8.8.8.8
- 9.9.9.9
```
### `cap_add, cap_drop`
添加或放弃容器的 Linux 能力Capabiliity
```sh
cap_add:
- ALL
cap_drop:
- NET_ADMIN
- SYS_ADMIN
```
### `dns_search`
配置 DNS 搜索域。可以是一个值,也可以是一个列表。
```sh
dns_search: example.com
dns_search:
- domain1.example.com
- domain2.example.com
```
### `working_dir, entrypoint, user, hostname, domainname, mem_limit, privileged, restart, stdin_open, tty, cpu_shares`
这些都是和 `docker run` 支持的选项类似。
```
cpu_shares: 73
working_dir: /code
entrypoint: /code/entrypoint.sh
user: postgresql
hostname: foo
domainname: foo.com
mem_limit: 1000000000
privileged: true
restart: always
stdin_open: true
tty: true
```

6
container/README.md Normal file
View File

@@ -0,0 +1,6 @@
# Docker 容器
容器是 Docker 又一核心概念。
简单的说,容器是独立运行的一个或一组应用,以及它们的运行态环境。对应的,虚拟机可以理解为模拟运行的一整套操作系统(提供了运行态环境和其他系统环境)和跑在上面的应用。
本章将具体介绍如何来管理一个容器,包括创建、启动和停止等。

39
container/daemon.md Normal file
View File

@@ -0,0 +1,39 @@
##后台(background)运行
更多的时候,需要让 Docker在后台运行而不是直接把执行命令的结果输出在当前宿主机下。此时可以通过添加 `-d` 参数来实现。
下面举两个例子来说明一下。
如果不使用 `-d` 参数运行容器。
```
$ sudo docker run ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
hello world
hello world
hello world
hello world
```
容器会把输出的结果(STDOUT)打印到宿主机上面
如果使用了 `-d` 参数运行容器。
```
$ sudo docker run -d ubuntu:14.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"
77b2dc01fe0f3f1265df143181e7b9af5e05279a884f4776ee75350ea9d8017a
```
此时容器会在后台运行并不会把输出的结果(STDOUT)打印到宿主机上面(输出结果可以用docker logs 查看)。
**注:** 容器是否会长久运行是和docker run指定的命令有关`-d` 参数无关。
使用 `-d` 参数启动后会返回一个唯一的 id也可以通过 `docker ps` 命令来查看容器信息。
```
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
77b2dc01fe0f ubuntu:14.04 /bin/sh -c 'while tr 2 minutes ago Up 1 minute agitated_wright
```
要获取容器的输出信息,可以通过 `docker logs` 命令。
```
$ sudo docker logs [container ID or NAMES]
hello world
hello world
hello world
. . .
```

66
container/enter.md Normal file
View File

@@ -0,0 +1,66 @@
## 进入容器
在使用 `-d` 参数时,容器启动后会进入后台。
某些时候需要进入容器进行操作,有很多种方法,包括使用 `docker attach` 命令或 `nsenter` 工具等。
### attach 命令
`docker attach` 是Docker自带的命令。下面示例如何使用该命令。
```
$ sudo docker run -idt ubuntu
243c32535da7d142fb0e6df616a3c3ada0b8ab417937c853a9e1c251f499f550
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
243c32535da7 ubuntu:latest "/bin/bash" 18 seconds ago Up 17 seconds nostalgic_hypatia
$sudo docker attach nostalgic_hypatia
root@243c32535da7:/#
```
但是使用 `attach` 命令有时候并不方便。当多个窗口同时 attach 到同一个容器的时候,所有窗口都会同步显示。当某个窗口因命令阻塞时,其他窗口也无法执行操作了。
### nsenter 命令
#### 安装
`nsenter` 工具在 util-linux 包2.23版本后包含。
如果系统中 util-linux 包没有该命令,可以按照下面的方法从源码安装。
```
$ cd /tmp; curl https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz | tar -zxf-; cd util-linux-2.24;
$ ./configure --without-ncurses
$ make nsenter && sudo cp nsenter /usr/local/bin
```
#### 使用
`nsenter` 可以访问另一个进程的名字空间。nsenter 要正常工作需要有 root 权限。
很不幸Ubuntu 14.04 仍然使用的是 util-linux 2.20。安装最新版本的 util-linux2.24)版,请按照以下步骤:
```
$ wget https://www.kernel.org/pub/linux/utils/util-linux/v2.24/util-linux-2.24.tar.gz; tar xzvf util-linux-2.24.tar.gz
$ cd util-linux-2.24
$ ./configure --without-ncurses && make nsenter
$ sudo cp nsenter /usr/local/bin
```
为了连接到容器,你还需要找到容器的第一个进程的 PID可以通过下面的命令获取。
```
PID=$(docker inspect --format "{{ .State.Pid }}" <container>)
```
通过这个 PID就可以连接到这个容器
```
$ nsenter --target $PID --mount --uts --ipc --net --pid
```
下面给出一个完整的例子。
```
$ sudo docker run -idt ubuntu
243c32535da7d142fb0e6df616a3c3ada0b8ab417937c853a9e1c251f499f550
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
243c32535da7 ubuntu:latest "/bin/bash" 18 seconds ago Up 17 seconds nostalgic_hypatia
$ PID=$(docker-pid 243c32535da7)
10981
$ sudo nsenter --target 10981 --mount --uts --ipc --net --pid
root@243c32535da7:/#
```
更简单的,建议大家下载
[.bashrc_docker](https://github.com/yeasy/docker_practice/raw/master/_local/.bashrc_docker),并将内容放到 .bashrc 中。
```
$ wget -P ~ https://github.com/yeasy/docker_practice/raw/master/_local/.bashrc_docker;
$ echo "[ -f ~/.bashrc_docker ] && . ~/.bashrc_docker" >> ~/.bashrc; source ~/.bashrc
```
这个文件中定义了很多方便使用 Docker 的命令,例如 `docker-pid` 可以获取某个容器的 PID`docker-enter` 可以进入容器或直接在容器内执行命令。
```
$ echo $(docker-pid <container>)
$ docker-enter <container> ls
```

View File

@@ -0,0 +1,28 @@
##导出和导入容器
###导出容器
如果要导出本地某个容器,可以使用 `docker export` 命令。
```
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7691a814370e ubuntu:14.04 "/bin/bash" 36 hours ago Exited (0) 21 hours ago test
$ sudo docker export 7691a814370e > ubuntu.tar
```
这样将导出容器快照到本地文件。
###导入容器快照
可以使用 `docker import` 从容器快照文件中再导入为镜像,例如
```
$ cat ubuntu.tar | sudo docker import - test/ubuntu:v1.0
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
test/ubuntu v1.0 9d37a6082e97 About a minute ago 171.3 MB
```
此外,也可以通过指定 URL 或者某个目录来导入,例如
```
$sudo docker import http://example.com/exampleimage.tgz example/imagerepo
```
*注:用户既可以使用 `docker load` 来导入镜像存储文件到本地镜像库,也可以使用 `docker import` 来导入一个容器快照到本地镜像库。这两者的区别在于容器快照文件将丢弃所有的历史记录和元数据信息(即仅保存容器当时的快照状态),而镜像存储文件将保存完整记录,体积也要大。此外,从容器快照文件导入时可以重新指定标签等元数据信息。

14
container/rm.md Normal file
View File

@@ -0,0 +1,14 @@
##删除容器
可以使用 `docker rm` 来删除一个处于终止状态的容器。
例如
```
$sudo docker rm trusting_newton
trusting_newton
```
如果要删除一个运行中的容器,可以添加 `-f` 参数。Docker 会发送 `SIGKILL` 信号给容器。
##清理所有处于终止状态的容器
`docker ps -a` 命令可以查看所有已经创建的包括终止状态的容器,如果数量太多要一个个删除可能会很麻烦,用 `docker rm $(docker ps -a -q)` 可以全部清理掉。
*注意:这个命令其实会试图删除所有的包括还在运行中的容器,不过就像上面提过的 `docker rm` 默认并不会删除运行中的容器。

51
container/run.md Normal file
View File

@@ -0,0 +1,51 @@
##启动容器
启动容器有两种方式一种是基于镜像新建一个容器并启动另外一个是将在终止状态stopped的容器重新启动。
因为 Docker 的容器实在太轻量级了,很多时候用户都是随时删除和新创建容器。
###新建并启动
所需要的命令主要为 `docker run`
例如,下面的命令输出一个 “Hello World”之后终止容器。
```
$ sudo docker run ubuntu:14.04 /bin/echo 'Hello world'
Hello world
```
这跟在本地直接执行 `/bin/echo 'hello world'` 几乎感觉不出任何区别。
下面的命令则启动一个 bash 终端,允许用户进行交互。
```
$ sudo docker run -t -i ubuntu:14.04 /bin/bash
root@af8bae53bdd3:/#
```
其中,`-t` 选项让Docker分配一个伪终端pseudo-tty并绑定到容器的标准输入上 `-i` 则让容器的标准输入保持打开。
在交互模式下,用户可以通过所创建的终端来输入命令,例如
```
root@af8bae53bdd3:/# pwd
/
root@af8bae53bdd3:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
```
当利用 `docker run` 来创建容器时Docker 在后台运行的标准操作包括:
* 检查本地是否存在指定的镜像,不存在就从公有仓库下载
* 利用镜像创建并启动一个容器
* 分配一个文件系统,并在只读的镜像层外面挂载一层可读写层
* 从宿主主机配置的网桥接口中桥接一个虚拟接口到容器中去
* 从地址池配置一个 ip 地址给容器
* 执行用户指定的应用程序
* 执行完毕后容器被终止
###启动已终止容器
可以利用 `docker start` 命令,直接将一个已经终止的容器启动运行。
容器的核心为所执行的应用程序,所需要的资源都是应用程序运行所必需的。除此之外,并没有其它的资源。可以在伪终端中利用 `ps``top` 来查看进程信息。
```
root@ba267838cc1b:/# ps
PID TTY TIME CMD
1 ? 00:00:00 bash
11 ? 00:00:00 ps
```
可见,容器中仅运行了指定的 bash 应用。这种特点使得 Docker 对资源的利用率极高,是货真价实的轻量级虚拟化。

17
container/stop.md Normal file
View File

@@ -0,0 +1,17 @@
##终止容器
可以使用 `docker stop` 来终止一个运行中的容器。
此外当Docker容器中指定的应用终结时容器也自动终止。
例如对于上一章节中只启动了一个终端的容器,用户通过 `exit` 命令或 `Ctrl+d` 来退出终端时,所创建的容器立刻终止。
终止状态的容器可以用 `docker ps -a` 命令看到。例如
```
sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ba267838cc1b ubuntu:14.04 "/bin/bash" 30 minutes ago Exited (0) About a minute ago trusting_newton
98e5efa7d997 training/webapp:latest "python app.py" About an hour ago Exited (0) 34 minutes ago backstabbing_pike
```
处于终止状态的容器,可以通过 `docker start` 命令来重新启动。
此外,`docker restart` 命令会将一个运行态的容器终止,然后再重新启动它。

View File

@@ -1,5 +0,0 @@
#容器安全
评估docker的安全性时主要考虑3个方面:
* 由内核中namespace和cgruoups提供的容器的内在安全
* docker程序本身的抗攻击性
加固内核安全性来影响容器的安全性

View File

@@ -1,3 +0,0 @@
##Control Groups
Control Groups 是LXC容器的另外一个关键组件由它来实现资源的审计和限制。他们提供了很多有用的特性还可以用来确保每个容器可以公平分享主机的内存、cpu、磁盘IO等资源更重要的是它可以保证当一个容器耗尽其中一个资源的时候不会连累主机宕机。
尽管他们不阻止容器之间相互访问、处理数据和进程但他们在防止拒绝服务攻击方面是必不可少的。在多用户的平台比如共有或则私有的paas上更加重要当某些应用程序表现不好的时候可以保证一直的uptime和性能。Control Groups 始于2006年从2.6.24之后被引入。

View File

@@ -1,11 +0,0 @@
##Docker Daemon Attack Surface
运行一个容器或则应用程序意味着运行一个docker 服务。docker服务要求root权限所以你需要了解一些重要的细节。
首先确保只有可信的用户可以访问docker服务因为这会直接导致很严重的后果。因为docker允许你在主机和容器之间共享文件夹这就容易让容器突破资源限制。比如当你在启动容器的时候将主机的/映射到容器的/host目录中那么容器就可以对主机做任何更改了。这听起来很疯狂不过你要知道几乎所有虚拟机系统都有在物理主机和虚拟机之间共享资源的限制所以需要你自己来考虑这一层的安全性。
比如当你使用一个web api来提供容器创建服务时要比平常更加注意参数的检查防止恶意的用户用精心准备的参数来创建带有任意参数的容器
因此REST API在docker0.5.2之后使用unix socket替代了绑定在127.0.0.1上的tcp socket后者容易遭受跨站脚本攻击。现在你可以使用增强的unix sockt权限来限制对控制socket的访问。
你依然可以将REST API发布到http服务上。不过一定要小心确认这里的安全机制确保只有可信的网络或则vpn或则受保护的stunnel和ssl认证可以对REST API进行访问。还可以使用https和认证HTTPS and certificates.
最近改进的linux namespace将很快可以实现使用非root用户来运行全功能的容器。这解决了因在容器和主机共享文件系统而引起的安全问题。
docker的终极目标是改进2个安全特性
* 将root用户的容器映射到主机上的非root用户减轻容器和主机之间因权限提升而引起的安全问题
* 允许docker服务在非root权限下运行委派操作请求到那些经过良好审计的子进程每个子进程拥有非常有限的权限虚拟网络设定文件系统管理、配置等等。
最后如果你在一个服务器上运行docker建议去掉docker之外的其他服务除了一些管理服务比如ssh 监控和进程管理工具nrpe clllectd等等。

View File

@@ -1,17 +0,0 @@
##Linux Kernel Capabilities
默认情况下docker启动的容器只严格使用一部分内核capabilities。这代表什么呢
这是一个root或非root 二分法粒度管理的访问控制系统。比如web服务进程只需要绑定一个低于1024的端口不需要用root来允许那么它只需要给它授权net_bind_service功能就可以了。还有很多其他的capabilities几乎所有需要root权限的仅需要指定一个部分capabilities就可以了。
这对容器的安全有很多好处通常的服务器需要允许一大堆root进程通常有ssh cron syslogd模块和网络配置工具等等。容器则不同因为大部分这种人物都被容器外面的基础设施处理了
* ssh可以被主机上ssh服务替代
* 硬件管理也无关紧要容器中也就无需执行udevd或则其他类似的服务
* 网络管理也都在主机上设置除非特殊需求ifconfig、route、ip也不需要了。
这意味这大部分情况下容器完全不需要“真正的”root权限。因此容器可以运行一个减少的capabilities集容器中的root也比“真正的root"拥有更少的capabilities,比如:
* 完全禁止任何mount操作
* 禁止直接访问宿主主机的socket
* 禁止访问一些文件系统的操作比如创建新的设备node等等
* 禁止模块加载
* 还有一些其他的
就算攻击者在容器中取得了root权限他能做的破坏也少了也不能获得主机的更高权限。
然而这不会影响普通的web apps恶意的用户会想各种办法来对你默认情况下docker丢弃了它需要的功能之外的其余部分。这里有一个白名单和黑名单在 Linux manpages可以看到完整的清单列表。当然你还可以启用你需要的额外capabilities。默认docker容器仅使用白名单的内capabilities。

View File

@@ -1,6 +0,0 @@
##Kernel Namespaces
docker容器和lxc容器很相似他们提供的安全特性也差不多。当你用docker run启动一个容器时在后台docker 为容器创建了一个namespace和contril groups的集合。
Namespaces提供了最初也是最直接的隔离在容器中运行的进程不会被运行在主机上的进程和容器发现他们之间相互影响也就小了。
每个容器都有自己的网络堆栈他们不能访问其他容器的sockets接口。不过如果在主机系统上做了相应的设置他们还是可以像跟主机交互一样的和其他容器交互通信。当你指定公共端口或则使用links来连接2个容器时他们就可以相互通信了。相互ping、udp、tcp都没问题也可以根据需要设定更严格的策略从网络架构上来看所有的容器通过主机的网桥接口相互通信就像物理机器通过物理交换机通信一样。
内核提供的namesapce和私有网络的代码有多成熟
内核namesapce从内核2.6.15之后被引入距今已经5年了在很多大型生产系统中被验证。他们的设计和灵感提出的时间更早openvz项目利用namespace重新封装他们的内核并合并到主流内核中。openvz最早的版本在2005所以他们的设计和实现都很成熟。

View File

@@ -1,7 +0,0 @@
##其它安全特性
Capabilities是现代linux内核提供的诸多安全特性中的一个docker可以利用现有的如TOMOYO, AppArmor, SELinux, GRSEC来增强安全性。为什么docker当前只启用capabilities,而不介入其他系统。
因为这样他就还可以有很多方法来加固docker主机下面是一些例子。
*你可以在内核中加载GRSEC和PAX这会增加很多安全检查。
*你可以使用一些有增强安全特性的发行版的模板比如带apparmor的模板和redhat系列带selinux dcoker策略这些模板提供了额外的安全特性。
*使用你自己喜欢的访问控制机制来定义你自己的安全策略。
像其他添加到docker容器的第三方工具一样比如网络拓扑和文件系统共享有很多这样的工具利用他们可以不用改变docker内核就可以加固现有的docker容器

View File

@@ -1,2 +0,0 @@
##结论
docker容器默认还是比较安全的特别是你如果注意在容器中使用非root权限来允许进程的话。你还可以添加额外的比如Apparmor, SELinux, GRSEC等你熟悉的加固方法。最后如果你对其他容器系统中的安全特性感兴趣你也可以在docker中实现它毕竟所有的东西都已经在内核中了。

8
coreos/README.md Normal file
View File

@@ -0,0 +1,8 @@
#CoreOS
CoreOS的设计是为你提供能够像谷歌一样的大型互联网公司一样的基础设施管理能力来动态扩展和管理的计算能力。
CoreOS的安装文件和运行依赖非常小,它提供了精简的Linux系统。它使用Linux容器在更高的抽象层来管理你的服务而不是通过常规的YUM和APT来安装包。
同时CoreOS几乎可以运行在任何平台Vagrant, Amazon EC2, QEMU/KVM, VMware 和 OpenStack 等等,甚至你所使用的硬件环境。

47
coreos/intro.md Normal file
View File

@@ -0,0 +1,47 @@
#CoreOS介绍
提起Docker我们不得不提的就是[CoreOS](https://coreos.com/).
CoreOS对Docker甚至容器技术的发展都带来了巨大的推动作用。
CoreOS是一种支持大规模服务部署的Linux系统。
CoreOS使得在基于最小化的现代操作系统上构建规模化的计算仓库成为了可能。
CoreOS是一个新的Linux发行版。通过重构CoreOS提供了运行现代基础设施的特性。
CoreOS的这些策略和架构允许其它公司像GoogleFacebook和Twitter那样高弹性的运行自己得服务。
CoreOS遵循Apache 2.0协议并且可以运行在现有的硬件或云提供商之上。
#CoreOS特性
##一个最小化操作系统
CoreOS被设计成一个来构建你平台的最小化的现代操作系统。
它比现有的Linux安装平均节省40%的RAM大约114M并允许从 PXE/iPXE 非常快速的启动。
##无痛更新
利用主动和被动双分区方案来更新OS使用分区作为一个单元而不是一个包一个包得更新。
这使得每次更新变得快速,可靠,而且很容易回滚。
##Docker容器
应用作为Docker容器运行在CoreOS上。容器以包得形式提供最大得灵活性并且可以在几毫秒启动。
##支持集群
CoreOS可以在一个机器上很好地运行但是它被设计用来搭建集群。
可以通过fleet很容易得使应用容器部署在多台机器上并且通过服务发现把他们连接在一起。
##分布式系统工具
内置诸如分布式锁和主选举等原生工具用来构建大规模分布式系统得构建模块。
##服务发现
很容易定位服务在集群的那里运行并当发生变化时进行通知。它是复杂高动态集群必不可少的。在CoreOS中构建高可用和自动故障负载。

104
coreos/intro_tools.md Normal file
View File

@@ -0,0 +1,104 @@
#CoreOS工具介绍
CoreOS提供了三大工具它们分别是服务发现容器管理和进程管理。
##使用etcd服务发现
CoreOS的第一个重要组件就是使用etcd来实现的服务发现。
如果你使用默认的样例cloud-config文件那么etcd会在启动时自动运行。
例如:
```
#cloud-config
hostname: coreos0
ssh_authorized_keys:
- ssh-rsa AAAA...
coreos:
units:
- name: etcd.service
command: start
- name: fleet.service
command: start
etcd:
name: coreos0
discovery: https://discovery.etcd.io/<token>
```
配置文件里有一个token获取它可以通过如下方式
访问地址
https://discovery.etcd.io/new
你将会获取一个包含你得teoken得URL。
##通过Docker进行容器管理
第二个组件就是docker它用来运行你的代码和应用。
每一个CoreOS的机器上都安装了它具体使用请参考本书其他章节。
##使用fleet进行进程管理
第三个CoreOS组件是fleet。
它是集群的分布式初始化系统。你应该使用fleet来管理你的docker容器的生命周期。
Fleet通过接受systemd单元文件来工作同时在你集群的机器上通过单元文件中编写的偏好来对它们进行调度。
首先让我们构建一个简单的可以运行docker容器的systemd单元。把这个文件保存在home目录并命名为hello.service
```
hello.service
[Unit]
Description=My Service
After=docker.service
[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill hello
ExecStartPre=-/usr/bin/docker rm hello
ExecStartPre=/usr/bin/docker pull busybox
ExecStart=/usr/bin/docker run --name hello busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"
ExecStop=/usr/bin/docker stop hello
```
然后,读取并启动这个单元:
```
$ fleetctl load hello.service
=> Unit hello.service loaded on 8145ebb7.../172.17.8.105
$ fleetctl start hello.service
=> Unit hello.service launched on 8145ebb7.../172.17.8.105
```
这样,你的容器将在集群里被启动。
下面我们查看下它的状态:
```
$ fleetctl status hello.service
● hello.service - My Service
Loaded: loaded (/run/fleet/units/hello.service; linked-runtime)
Active: active (running) since Wed 2014-06-04 19:04:13 UTC; 44s ago
Main PID: 27503 (bash)
CGroup: /system.slice/hello.service
├─27503 /bin/bash -c /usr/bin/docker start -a hello || /usr/bin/docker run --name hello busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"
└─27509 /usr/bin/docker run --name hello busybox /bin/sh -c while true; do echo Hello World; sleep 1; done
Jun 04 19:04:57 core-01 bash[27503]: Hello World
..snip...
Jun 04 19:05:06 core-01 bash[27503]: Hello World
```
我们可以停止容器:
```
fleetctl destroy hello.service
```
至此就是CoreOS提供的三大工具。

102
coreos/quickstart.md Normal file
View File

@@ -0,0 +1,102 @@
#快速搭建CoreOS集群
在这里我们要搭建一个集群环境,毕竟单机环境没有什么挑战不是?
然后为了在你的电脑运行一个集群环境我们使用Vagrant。
*Vagrant的使用这里不再阐述请自行学习*
如果你第一次接触CoreOS这样的分布式平台运行一个集群看起来好像一个很复杂的任务这里我们给你展示在本地快速搭建一个CoreOS集群环境是多么的容易。
##准备工作
首先要确认在你本地的机器上已经安装了最新版本的Virtualbox, Vagrant 和 git。
这是我们可以在本地模拟集群环境的前提条件,如果你已经拥有,请继续,否则自行搜索学习。
##配置工作
从CoreOS官方代码库获取基本配置并进行修改
首先,获取模板配置文件
```
git clone https://github.com/coreos/coreos-vagrant
cd coreos-vagrant
cp user-data.sample user-data
```
获取新的token
```
curl https://discovery.etcd.io/new
```
把获取的token放到user-data文件中示例如下
```
#cloud-config
coreos:
etcd:
discovery: https://discovery.etcd.io/<token>
```
##启动集群
默认情况下CoreOS Vagrantfile 将会启动单机。
我们需要复制并修改config.rb.sample文件.
复制文件
```
cp config.rb.sample config.rb
```
修改集群配置参数num_instances为3。
启动集群
```
vagrant up
=>
Bringing machine 'core-01' up with 'virtualbox' provider...
Bringing machine 'core-02' up with 'virtualbox' provider...
Bringing machine 'core-03' up with 'virtualbox' provider...
==> core-01: Box 'coreos-alpha' could not be found. Attempting to find and install...
core-01: Box Provider: virtualbox
core-01: Box Version: >= 0
==> core-01: Adding box 'coreos-alpha' (v0) for provider: virtualbox
core-01: Downloading: http://storage.core-os.net/coreos/amd64-usr/alpha/coreos_production_vagrant.box
core-01: Progress: 46% (Rate: 6105k/s, Estimated time remaining: 0:00:16)
```
添加ssh的公匙
```
ssh-add ~/.vagrant.d/insecure_private_key
```
连接集群中的第一台机器
```
vagrant ssh core-01 -- -A
```
##测试集群
使用fleet来查看机器运行状况
```
fleetctl list-machines
=>
MACHINE IP METADATA
517d1c7d... 172.17.8.101 -
cb35b356... 172.17.8.103 -
17040743... 172.17.8.102 -
```
如果你也看到了如上类似的信息,恭喜,本地基于三台机器的集群已经成功启动,是不是很简单。
那么之后你就可以基于CoreOS的三大工具做任务分发分布式存储等很多功能了。

BIN
cover.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

BIN
cover_small.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -1,5 +1,4 @@
#Docker 数据管理
这一章介绍如何在docker内部以及容器之间管理数据
在容器中管理数据的2个主要方式
* Data volumes
* Data volume containers.
# Docker 数据管理
这一章介绍如何在 Docker 内部以及容器之间管理数据,在容器中管理数据主要有两种方式:
* 数据卷Data volumes
* 数据卷容器(Data volume containers

View File

@@ -1,16 +1,23 @@
##数据卷容器
如果你有一些持续更新的数据需要在容器之间共享,最好创建Data Volume Container然后加载它。现在就来创建一个命名的数据卷容器
## 数据卷容器
如果你有一些持续更新的数据需要在容器之间共享,最好创建数据卷容器
数据卷容器,其实就是一个正常的容器,专门用来提供数据卷供其它容器挂载的。
首先,创建一个名为 dbdata 的数据卷容器:
```
$ sudo docker run -d -v /dbdata --name dbdata training/postgres echo Data-only container for postgres
```
然后,你可以在其他容器中使用--volumes-from 来挂载/dbdata
然后,在其他容器中使用 `--volumes-from` 来挂载 dbdata 容器中的数据卷。
```
$ sudo docker run -d --volumes-from dbdata --name db1 training/postgres
$ sudo docker run -d --volumes-from dbdata --name db2 training/postgres
```
可以使用多个--volumes-from 参数来从多个容器挂载多个数据卷
也可以从其他已经挂载了容器卷的容器来挂载数据卷
可以使用超过一个的 `--volumes-from` 参数来指定从多个容器挂载不同的数据卷
也可以从其他已经挂载了数据卷的容器来级联挂载数据卷
```
$ sudo docker run -d --name db3 --volumes-from db1 training/postgres
```
如果你移除了挂载的容器包括初始容器或者后来的db1 db2这些卷在有容器使用它的时候不会被删除。这可以让我们在容器之间升级和移动数据
*注意:使用 `--volumes-from` 参数所挂载数据卷的容器自己并不需要保持在运行状态
如果删除了挂载的容器(包括 dbdata、db1 和 db2数据卷并不会被自动删除。如果要删除一个数据卷必须在删除最后一个还挂载着它的容器时使用 `docker rm -v` 命令来指定同时删除关联的容器。
这可以让用户在容器之间升级和移动数据卷。具体的操作将在下一节中进行讲解。

Some files were not shown because too many files have changed in this diff Show More