标签:pass 3.1 style data host restart http ini containe
docker-compose.yml文件内容:
version: ‘3.1‘
services:
mongo:
container_name: mongo
image: mongo
network_mode: host
restart: always
volumes:
- ./data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 123456a
启动容器
docker-compose up -d
进入容器,进入mongo命令行:
docker exec -it mongo bash
mongo
新建数据库,添加普通用户
use admin; db.auth(‘root‘,‘123456a‘); use bruce; db.createUser({ user: ‘bruce‘, pwd: ‘a123456‘, roles: [{role: ‘readWrite‘,db: ‘bruce‘}] });
标签:pass 3.1 style data host restart http ini containe
原文地址:https://www.cnblogs.com/windyWu/p/10207142.html