网上有很多关于docker-compose安装mongodb的笔记,但是对于实用config启动记录太少,我踩了一下的坑重要把这些问题都走了一遍,记录下帮助那些跟我一样遇到问题的人
version: ‘3.8‘
networks:
mynet:
external: true
services:
mongodb:
image: mongo:4.2.6
networks:
- mynet
env_file:
- ./.env
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /data/mongo_cluster/2727/db:/data/mongo/db
- /data/mongo_cluster/2727/log:/data/mongo/log
- /data/mongo_cluster/2727/2727.conf:/data/mongo/mongo.conf
container_name: mongo_main
environment:
- MONGO_INITDB_ROOT_USERNAME=qumogu
- MONGO_INITDB_ROOT_PASSWORD=xxxxsss
command: mongod -- config /data/mongo/mongo.conf
ports:
- 2727:27017
restart: always
logging:
driver: json-file
options:
max-file: ‘2‘
max-size: 100m
logpath=/data/mongo/log/mongo.log
logappend=true
fork = true
port = 27027
dbpath=/data/mongo/db
cpu = true
auth = true
bind_ip = 0.0.0.0
maxConns = 100
objcheck = true
pidfilepath = /data/mongo/run/mongo.pid
docker-compose.yml的配置问题:
mongo.conf的配置问题
version: ‘3.8‘
networks:
mynet:
external: true
services:
mongodb:
image: mongo:4.2.6
networks:
- mynet
env_file:
- ./.env
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /data/mongo_cluster/2727/db:/data/db
- /data/mongo_cluster/2727/opt:/data/configdb
container_name: mongo_main
environment:
- MONGO_INITDB_ROOT_USERNAME=qumogu
- MONGO_INITDB_ROOT_PASSWORD=xxxxsss
# command: --auth --bind_ip 0.0.0.0 --logpath=/data/configdb/log/db.log
command: --config /data/configdb/mongo.conf
ports:
- 2727:27017
restart: always
logging:
driver: json-file
options:
max-file: ‘2‘
max-size: 100m
port = 27017
dbpath=/data/db
maxConns = 10000
auth = true
bind_ip = 0.0.0.0
logpath=/data/configdb/log/mongo.log
logappend=true
objcheck = true
docker-compose使用--config启动mongodb出错的采坑记录
原文:https://www.cnblogs.com/qumogu/p/12943912.html