2018-12-14 19:08:14 +08:00
|
|
|
|
## [MongoDB](https://hub.docker.com/_/mongo/)
|
2016-12-10 17:00:25 +08:00
|
|
|
|
|
|
|
|
|
### 基本信息
|
2017-11-24 10:19:15 +08:00
|
|
|
|
|
2016-12-10 17:00:25 +08:00
|
|
|
|
[MongoDB](https://en.wikipedia.org/wiki/MongoDB) 是开源的 NoSQL 数据库实现。
|
|
|
|
|
|
2018-12-15 23:04:32 +08:00
|
|
|
|
该仓库位于 `https://hub.docker.com/_/mongo/` ,提供了 MongoDB 2.x ~ 4.x 各个版本的镜像。
|
2016-12-10 17:00:25 +08:00
|
|
|
|
|
|
|
|
|
### 使用方法
|
2017-11-24 10:19:15 +08:00
|
|
|
|
|
2016-12-10 17:00:25 +08:00
|
|
|
|
默认会在 `27017` 端口启动数据库。
|
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2017-11-24 10:19:15 +08:00
|
|
|
|
$ docker run --name mongo -d mongo
|
2016-12-10 17:00:25 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
使用其他应用连接到容器,可以用
|
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2016-12-10 17:00:25 +08:00
|
|
|
|
$ docker run --name some-app --link some-mongo:mongo -d application-that-uses-mongo
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
或者通过 `mongo`
|
|
|
|
|
|
2017-11-22 11:13:23 +08:00
|
|
|
|
```bash
|
2017-12-01 17:32:39 +08:00
|
|
|
|
$ docker run -it --rm \
|
|
|
|
|
--link some-mongo:mongo \
|
|
|
|
|
mongo \
|
|
|
|
|
sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'
|
2016-12-10 17:00:25 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Dockerfile
|
|
|
|
|
|
2017-11-01 00:36:57 +08:00
|
|
|
|
请到 https://github.com/docker-library/docs/tree/master/mongo 查看。
|