docker-compose.yml
version: '3.8'
services:
mongo:
image: mongo
restart: always
container_name: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 密码
ports:
- 27017:27017
volumes:
- /data/docker/mongo/db:/var/lib/mongodb # 挂载数据目录
- /data/docker/mongo/log:/var/log/mongodb # 挂载日志目录
- /data/docker/mongo/conf:/etc/mongo # 挂载配置目录
mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp: