模板如下:
# docker-compose-mongo.yaml
# command:启动是的命令行参数,添加认证auth
version: '2'
services:
mongodb:
container_name: zxlmongodb
image: mongo:latest
ports:
- 27017:27017
# - "28017:28017"
volumes:
- "./data/configdb:/data/configdb"
- "./data/db:/data/db"
command: mongod --auth
tty: true
启动命令:
docker-compose -f docker-compose-mongo.yaml up -d
网友评论