2018-12-14 11:08:14 +00:00
|
|
|
|
## [MongoDB](https://hub.docker.com/_/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 数据库实现。
|
|
|
|
|
|
2018-12-15 15:04:32 +00:00
|
|
|
|
该仓库位于 `https://hub.docker.com/_/mongo/` ,提供了 MongoDB 2.x ~ 4.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
|
2017-12-01 09:32:39 +00: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 09:00:25 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Dockerfile
|
|
|
|
|
|
2017-10-31 16:36:57 +00:00
|
|
|
|
请到 https://github.com/docker-library/docs/tree/master/mongo 查看。
|