This commit is contained in:
khs1994
2017-11-22 11:13:23 +08:00
parent c3c3cf98cb
commit 7cbdf27d93
30 changed files with 189 additions and 193 deletions

View File

@@ -8,7 +8,7 @@
### 使用方法
默认会启动一个最小化的 CentOS 环境。
```sh
```bash
$ docker run --name some-centos -i -t centos bash
bash-4.2#
```

View File

@@ -8,19 +8,19 @@
### 使用方法
默认会在 `27017` 端口启动数据库。
```sh
```bash
$ docker run --name some-mongo -d mongo
```
使用其他应用连接到容器,可以用
```sh
```bash
$ docker run --name some-app --link some-mongo:mongo -d application-that-uses-mongo
```
或者通过 `mongo`
```sh
```bash
$ docker run -it --link some-mongo:mongo --rm mongo sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'
```

View File

@@ -8,17 +8,17 @@
### 使用方法
默认会在 `3306` 端口启动数据库。
```
```bash
$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql
```
之后就可以使用其它应用来连接到该容器。
```
```bash
$ docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql
```
或者通过 `mysql`
```
```bash
$ 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"'
```

View File

@@ -8,30 +8,30 @@
### 使用方法
下面的命令将作为一个静态页面服务器启动。
```
```bash
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
```
用户也可以不使用这种映射方式,通过利用 Dockerfile 来直接将静态页面内容放到镜像中,内容为
```
```bash
FROM nginx
COPY static-html-directory /usr/share/nginx/html
```
之后生成新的镜像,并启动一个容器。
```
```bash
$ docker build -t some-content-nginx .
$ docker run --name some-nginx -d some-content-nginx
```
开放端口,并映射到本地的 `8080` 端口。
```
```bash
docker run --name some-nginx -d -p 8080:80 some-content-nginx
```
Nginx的默认配置文件路径为 `/etc/nginx/nginx.conf`,可以通过映射它来使用本地的配置文件,例如
```
```bash
docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx
```
使用配置文件时,为了在容器中正常运行,需要保持 `daemon off;`

View File

@@ -8,21 +8,21 @@
### 使用方法
在项目中创建一个 Dockerfile。
```
```bash
FROM node:0.10-onbuild
# replace this with your application's default port
EXPOSE 8888
```
然后创建镜像,并启动容器。
```
```bash
$ docker build -t my-nodejs-app
$ docker run -it --rm --name my-running-app my-nodejs-app
```
也可以直接运行一个简单容器。
```
```bash
$ 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
```

View File

@@ -8,12 +8,12 @@
### 使用方法
默认会在 `6379` 端口启动数据库。
```
```bash
$ docker run --name some-redis -d redis
```
另外还可以启用 [持久存储](http://redis.io/topics/persistence)。
```
```bash
$ docker run --name some-redis -d redis redis-server --appendonly yes
```
@@ -21,12 +21,12 @@ $ docker run --name some-redis -d redis redis-server --appendonly yes
使用其他应用连接到容器,可以用
```
```bash
$ docker run --name some-app --link some-redis:redis -d application-that-uses-redis
```
或者通过 `redis-cli`
```
```bash
$ 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"'
```

View File

@@ -8,7 +8,7 @@
### 使用方法
默认会启动一个最小化的 Ubuntu 环境。
```
```bash
$ docker run --name some-ubuntu -i -t ubuntu
root@523c70904d54:/#
```

View File

@@ -8,7 +8,7 @@
### 使用方法
启动容器需要 MySQL 的支持,默认端口为 `80`
```
```bash
$ docker run --name some-wordpress --link some-mysql:mysql -d wordpress
```
启动 WordPress 容器时可以指定的一些环境参数包括: