Skip to content

Commit 6fa5159

Browse files
committed
Add new chapters to introduce the popular repositories
1 parent 1faf0ee commit 6fa5159

File tree

11 files changed

+207
-2
lines changed

11 files changed

+207
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Docker —— 从入门到实践
22
===============
33

4-
v0.2.6
4+
v0.2.7
55

66
[Docker](docker.com)是个伟大的项目,它彻底释放了虚拟化的威力,让应用的分发、部署和管理都变得前所未有的高效和轻松!
77

@@ -23,6 +23,7 @@ v0.2.6
2323
完成仓库章节;
2424
重写安全章节;
2525
修正底层实现章节的架构、名字空间、控制组、文件系统、容器格式等内容。
26+
添加对常见仓库和镜像的介绍。
2627
* 0.2: 2014-09-18
2728
对照官方文档重写介绍、基本概念、安装、镜像、容器、仓库、数据管理、网络等章节;
2829
添加底层实现章节;

SUMMARY.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,14 @@
6767
* [容器格式](underly/container_format.md)
6868
* [网络](underly/network.md)
6969
* [附录一:命令查询](appendix_command/README.md)
70-
* [附录二:资源链接](appendix_resources/README.md)
70+
* [附录二:常见仓库介绍](appendix_repo/README.md)
71+
* [Ubuntu](appendix_repo/ubuntu.md)
72+
* [CentOS](appendix_repo/centos.md)
73+
* [MySQL](appendix_repo/mysql.md)
74+
* [MongoDB](appendix_repo/mongodb.md)
75+
* [Redis](appendix_repo/redis.md)
76+
* [Nginx](appendix_repo/nginx.md)
77+
* [WordPress](appendix_repo/wordpress.md)
78+
* [Node.js](appendix_repo/nodejs.md)
79+
* [附录三:资源链接](appendix_resources/README.md)
7180

appendix_repo/README.md

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

appendix_repo/centos.md

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

appendix_repo/mongodb.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## [MongoDB](https://registry.hub.docker.com/_/mongo/)
2+
3+
### 基本信息
4+
[MongoDB](https://en.wikipedia.org/wiki/MongoDB)是开源的NoSQL数据库实现。
5+
该仓库提供了MongoDB从2.2到2.7各个版本的镜像。
6+
7+
### 使用方法
8+
默认会在`27017`端口启动数据库。
9+
```
10+
$ sudo docker run --name some-mongo -d mongo
11+
```
12+
13+
使用其他应用连接到容器,可以用
14+
```
15+
$ sudo docker run --name some-app --link some-mongo:mongo -d application-that-uses-mongo
16+
```
17+
或者通过`mongo`
18+
```
19+
$ 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"'
20+
```
21+
22+
### Dockerfile
23+
* [2.2版本](https://github.com/docker-library/mongo/blob/77c841472ccb6cc87fea1218269d097405edc6cb/2.2/Dockerfile)
24+
* [2.4版本](https://github.com/docker-library/mongo/blob/807078cb7b5f0289f6dabf9f6875d5318122bc30/2.4/Dockerfile)
25+
* [2.6版本](https://github.com/docker-library/mongo/blob/77c841472ccb6cc87fea1218269d097405edc6cb/2.6/Dockerfile)
26+
* [2.7版本](https://github.com/docker-library/mongo/blob/807078cb7b5f0289f6dabf9f6875d5318122bc30/2.7/Dockerfile)

appendix_repo/mysql.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## [MySQL](https://registry.hub.docker.com/_/mysql/)
2+
3+
### 基本信息
4+
[MySQL](https://en.wikipedia.org/wiki/MySQL)是开源的关系数据库实现。
5+
该仓库提供了MySQL各个版本的镜像,包括5.6系列、5.7系列等。
6+
7+
### 使用方法
8+
默认会在`3306`端口启动数据库。
9+
```
10+
$ sudo docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql
11+
```
12+
之后就可以使用其它应用来连接到该容器。
13+
```
14+
$ sudo docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql
15+
```
16+
或者通过`mysql`
17+
```
18+
$ 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"'
19+
```
20+
21+
### Dockerfile
22+
* [5.6版本](https://github.com/docker-library/mysql/blob/7461a52b43f06839a4d8723ae8841f4cb616b3d0/5.6/Dockerfile)
23+
* [5.7版本](https://github.com/docker-library/mysql/blob/7461a52b43f06839a4d8723ae8841f4cb616b3d0/5.7/Dockerfile)

appendix_repo/nginx.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## [Nginx](https://registry.hub.docker.com/_/nginx/)
2+
3+
### 基本信息
4+
[Nginx](https://en.wikipedia.org/wiki/Nginx)是开源的高效的Web服务器实现,支持HTTP、HTTPS、SMTP、POP3、IMAP等协议。
5+
该仓库提供了Nginx从1.0到1.7各个版本的镜像。
6+
7+
### 使用方法
8+
下面的命令将作为一个静态页面服务器启动。
9+
```
10+
$ sudo docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
11+
```
12+
用户也可以不使用这种映射方式,通过利用Dockerfile来直接将静态页面内容放到镜像中,内容为
13+
```
14+
FROM nginx
15+
COPY static-html-directory /usr/share/nginx/html
16+
```
17+
之后生成新的镜像,并启动一个容器。
18+
```
19+
$ sudo docker build -t some-content-nginx .
20+
$ sudo docker run --name some-nginx -d some-content-nginx
21+
```
22+
开放端口,并映射到本地的`8080`端口。
23+
```
24+
sudo docker run --name some-nginx -d -p 8080:80 some-content-nginx
25+
```
26+
27+
Nginx的默认配置文件路径为`/etc/nginx/nginx.conf`,可以通过映射它来使用本地的配置文件,例如
28+
```
29+
docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
30+
```
31+
使用配置文件时,为了在容器中正常运行,需要保持`daemon off;`
32+
33+
### Dockerfile
34+
* [1到1.7版本](https://github.com/nginxinc/docker-nginx/blob/3713a0157083eb4776e71f5a5aef4b2a5bc03ab1/Dockerfile)

appendix_repo/nodejs.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## [Node.js](https://registry.hub.docker.com/_/node/)
2+
3+
### 基本信息
4+
[Node.js](https://en.wikipedia.org/wiki/Node.js)是基于JavaScript的可扩展服务端和网络软件开发平台。
5+
该仓库提供了Node.js从0.8到0.11各个版本的镜像。
6+
7+
### 使用方法
8+
在项目中创建一个Dockerfile。
9+
```
10+
FROM node:0.10-onbuild
11+
# replace this with your application's default port
12+
EXPOSE 8888
13+
```
14+
然后创建镜像,并启动容器
15+
```
16+
$ sudo docker build -t my-nodejs-app
17+
$ sudo docker run -it --rm --name my-running-app my-nodejs-app
18+
```
19+
20+
也可以直接运行一个简单容器。
21+
```
22+
$ 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
23+
```
24+
25+
### Dockerfile
26+
* [0.8版本](https://github.com/docker-library/node/blob/d017d679e92e84a810c580cdb29fcdbba23c2bb9/0.8/Dockerfile)
27+
* [0.10版本](https://github.com/docker-library/node/blob/913a225f2fda34d6a811fac1466e4f09f075fcf6/0.10/Dockerfile)
28+
* [0.11版本](https://github.com/docker-library/node/blob/d017d679e92e84a810c580cdb29fcdbba23c2bb9/0.11/Dockerfile)

appendix_repo/redis.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## [Redis](https://registry.hub.docker.com/_/redis/)
2+
3+
### 基本信息
4+
[Redis](https://en.wikipedia.org/wiki/Redis)是开源的内存Key-Value数据库实现。
5+
该仓库提供了Redis从2.6到2.8.9各个版本的镜像。
6+
7+
### 使用方法
8+
默认会在`6379`端口启动数据库。
9+
```
10+
$ sudo docker run --name some-redis -d redis
11+
```
12+
另外还可以启用[持久存储](http://redis.io/topics/persistence)
13+
```
14+
$ sudo docker run --name some-redis -d redis redis-server --appendonly yes
15+
```
16+
默认数据存储位置在`VOLUME/data`。可以使用`--volumes-from some-volume-container``-v /docker/host/dir:/data`将数据存放到本地。
17+
18+
使用其他应用连接到容器,可以用
19+
```
20+
$ sudo docker run --name some-app --link some-redis:redis -d application-that-uses-redis
21+
```
22+
或者通过`redis-cli`
23+
```
24+
$ 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"'
25+
```
26+
27+
### Dockerfile
28+
* [2.6版本](https://github.com/docker-library/redis/blob/02d9cd887a4e0d50db4bb085eab7235115a6fe4a/2.6.17/Dockerfile)
29+
* [最新2.8版本](https://github.com/docker-library/redis/blob/d0665bb1bbddd4cc035dbc1fc774695fa534d648/2.8.13/Dockerfile)

appendix_repo/ubuntu.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## [Ubuntu](https://registry.hub.docker.com/_/ubuntu/)
2+
3+
### 基本信息
4+
[Ubuntu](https://en.wikipedia.org/wiki/Ubuntu)是流行的Linux发行版,其自带软件版本往往较新一些。
5+
该仓库提供了Ubuntu从12.04到14.10各个版本的镜像。
6+
7+
### 使用方法
8+
默认会启动一个最小化的Ubuntu环境。
9+
```
10+
$ sudo docker run --name some-ubuntu -i -t ubuntu
11+
root@523c70904d54:/#
12+
```
13+
14+
### Dockerfile
15+
* [12.04版本](https://github.com/tianon/docker-brew-ubuntu-core/blob/2b105575647a7e2030ff344d427c3920b89e17a9/precise/Dockerfile)
16+
* [14.04版本](https://github.com/tianon/docker-brew-ubuntu-core/blob/2b105575647a7e2030ff344d427c3920b89e17a9/trusty/Dockerfile)
17+
* [14.10版本](https://github.com/tianon/docker-brew-ubuntu-core/blob/2b105575647a7e2030ff344d427c3920b89e17a9/utopic/Dockerfile)

appendix_repo/wordpress.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## [WordPress](https://registry.hub.docker.com/_/wordpress/)
2+
3+
### 基本信息
4+
[WordPress](https://en.wikipedia.org/wiki/WordPress)是开源的Blog和内容管理系统框架,它基于PhP和MySQL。
5+
该仓库提供了WordPress 4.0版本的镜像。
6+
7+
### 使用方法
8+
启动容器需要MySQL的支持,默认端口为`80`
9+
```
10+
$ sudo docker run --name some-wordpress --link some-mysql:mysql -d wordpress
11+
```
12+
启动WordPress容器时可以指定的一些环境参数包括
13+
* `-e WORDPRESS_DB_USER=...` 缺省为“root”
14+
* `-e WORDPRESS_DB_PASSWORD=...` 缺省为连接mysql容器的环境变量`MYSQL_ROOT_PASSWORD`的值
15+
* `-e WORDPRESS_DB_NAME=...` 缺省为“wordpress”
16+
* `-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串
17+
18+
### Dockerfile
19+
* [4.0版本](https://github.com/docker-library/wordpress/blob/aee00669e7c43f435f021cb02871bffd63d5677a/Dockerfile)

0 commit comments

Comments
 (0)