1. 编写docker-compose.yaml文件
version: "3"
services:
mongo:
image: mongo:4.2.6
ports:
- 27017:27017
volumes:
- ./data:/data/db:rw
- ./configdb:/data/configdb:rw
environment:
- TZ=Asia/Shanghai
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
container_name: mongo
2. 服务启动
docker-compose up -d
标签:compose,服务,mongo,启动,MongoDB,ROOT,configdb,INITDB,data
From: https://www.cnblogs.com/shenjian-online/p/16796085.html