“Docker mongo”的版本间的差异
跳到导航
跳到搜索
第1行: | 第1行: | ||
<pre> | <pre> | ||
+ | #Sep 23 2021 | ||
+ | vi docker-compose.yml | ||
+ | |||
+ | version: "3.1" | ||
+ | services: | ||
+ | |||
+ | mongodb: | ||
+ | image: mongo:4.2 | ||
+ | container_name: mongodb4.2 | ||
+ | ports: | ||
+ | - "27018:27017" | ||
+ | #- "27017-27019:27017-27019" | ||
+ | volumes: | ||
+ | #- /Users/Pie/docker-lnmp/conf/mongodb/:/etc/mongo/:rw | ||
+ | - ./mongodb/config/:/etc/mongo/ | ||
+ | #- ./mongodb/config/mongod.conf:/etc/mongo/mongod.conf | ||
+ | - /data/db_data/mongodb/:/data/db/:rw | ||
+ | #- /data/db_data/mongodb/:/var/lib/mongo/:rw | ||
+ | - /data/log/mongodb/:/var/log/mongodb/:rw | ||
+ | environment: | ||
+ | #设置后台登录用户和密码,没设置默认为:guest/guest | ||
+ | MONGO_INITDB_ROOT_USERNAME: "root" | ||
+ | MONGO_INITDB_ROOT_PASSWORD: example36 | ||
+ | TZ: "Asia/Shanghai" | ||
+ | restart: always | ||
+ | command: --config /etc/mongo/mongod.conf | ||
+ | networks: | ||
+ | - default | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | err | ||
+ | mongodb4.2 | 2021-09-23T10:33:04.391+0800 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/log/mongodb/mongod.log" | ||
+ | |||
+ | chmod -R 0777 /data/log/mongodb/ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
cat docker-compose.yml | cat docker-compose.yml |
2021年9月23日 (四) 02:50的版本
#Sep 23 2021 vi docker-compose.yml version: "3.1" services: mongodb: image: mongo:4.2 container_name: mongodb4.2 ports: - "27018:27017" #- "27017-27019:27017-27019" volumes: #- /Users/Pie/docker-lnmp/conf/mongodb/:/etc/mongo/:rw - ./mongodb/config/:/etc/mongo/ #- ./mongodb/config/mongod.conf:/etc/mongo/mongod.conf - /data/db_data/mongodb/:/data/db/:rw #- /data/db_data/mongodb/:/var/lib/mongo/:rw - /data/log/mongodb/:/var/log/mongodb/:rw environment: #设置后台登录用户和密码,没设置默认为:guest/guest MONGO_INITDB_ROOT_USERNAME: "root" MONGO_INITDB_ROOT_PASSWORD: example36 TZ: "Asia/Shanghai" restart: always command: --config /etc/mongo/mongod.conf networks: - default err mongodb4.2 | 2021-09-23T10:33:04.391+0800 F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "/var/log/mongodb/mongod.log" chmod -R 0777 /data/log/mongodb/ cat docker-compose.yml version: "3" services: mongodb: image: mongo:4.2 container_name: mongodb4.2 ports: - "27017-27019:27017-27019" volumes: # - /Users/Pie/docker-lnmp/conf/mongodb/:/etc/mongo/:rw - /data/db_data/mongodb/:/data/db/:rw - /data/log/mongodb/:/var/log/mongodb/:rw environment: #设置后台登录用户和密码,没设置默认为:guest/guest MONGO_INITDB_ROOT_USERNAME: "root" MONGO_INITDB_ROOT_PASSWORD: example36 TZ: "Asia/Shanghai" restart: always networks: - default