2017-11-24 02:19:15 +00:00
|
|
|
## [MongoDB](https://store.docker.com/images/mongo/)
|
2016-12-10 09:00:25 +00:00
|
|
|
|
|
|
|
### 基本信息
|
2017-11-24 02:19:15 +00:00
|
|
|
|
2016-12-10 09:00:25 +00:00
|
|
|
[MongoDB](https://en.wikipedia.org/wiki/MongoDB) 是开源的 NoSQL 数据库实现。
|
|
|
|
|
2017-11-24 02:19:15 +00:00
|
|
|
该仓库位于 https://store.docker.com/images/mongo/ ,提供了 MongoDB 2.x ~ 3.x 各个版本的镜像。
|
2016-12-10 09:00:25 +00:00
|
|
|
|
|
|
|
### 使用方法
|
2017-11-24 02:19:15 +00:00
|
|
|
|
2016-12-10 09:00:25 +00:00
|
|
|
默认会在 `27017` 端口启动数据库。
|
|
|
|
|
2017-11-22 03:13:23 +00:00
|
|
|
```bash
|
2017-11-24 02:19:15 +00:00
|
|
|
$ docker run --name mongo -d mongo
|
2016-12-10 09:00:25 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
使用其他应用连接到容器,可以用
|
|
|
|
|
2017-11-22 03:13:23 +00:00
|
|
|
```bash
|
2016-12-10 09:00:25 +00:00
|
|
|
$ docker run --name some-app --link some-mongo:mongo -d application-that-uses-mongo
|
|
|
|
```
|
|
|
|
|
|
|
|
或者通过 `mongo`
|
|
|
|
|
2017-11-22 03:13:23 +00:00
|
|
|
```bash
|
2016-12-10 09:00:25 +00:00
|
|
|
$ 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
|
|
|
|
|
2017-10-31 16:36:57 +00:00
|
|
|
请到 https://github.com/docker-library/docs/tree/master/mongo 查看。
|