1. Initialize Docker:
-V Set Docker and host shared directory, format Hostpath:dockercontainerpath
-P Port Mapping
--name, container name
CentOS, mirroring
Docker run-d-P 27017:27017-v/home/mongodb/:/data/mongodb/--name centos-mongodb CentOS
Start Docker start Centos-mongodb
2. Enter the container
Docker exec-it Centos-mongodb/bin/bash
3. Copy MONGO installation files from the shared directory
Cp/data/mongodb/mongodb-linux-x86_64-3.2.8.tgz/usr/local/src
4. Decompression and Installation
TAR-ZXVF mongodb-linux-x86_64-3.2.8.tgz-c. /#解压mongo到/usr/local/
5, configuration Mongo
cd/usr/local/
MV mongodb-linux-x86_64-3.2.8/mongodb-3.2.8/
CD mongodb-3.2.8
mkdir conf
CD conf
Vim mongo.conf #新建mongo配置文件如下
---------------------------------------------------------------
DBPath =/data/mongodb/data #数据文件存放目录
LogPath =/data/mongodb/logs/mongodb.log #日志文件存放目录
Port = 27017 #端口
Fork = True #以守护程序的方式启用, which runs in the background
Nohttpinterface = True
---------------------------------------------------------------
If the/data/mongodb folder does not exist, first create
mkdir data
mkdir logs
6. Start MONGO
Cd/usr/local/mongodb-3.2.8/bin
./mongod--config. /conf/mongo.conf
Installing MongoDB under Linux