Linux创建映射文件
mkdir /opt/docker/mongo
docker安装mongo
docker run --name mongo -p 27017:27017 -v /opt/docker/mongo:/data/db -d mongo:latest --auth
配置mongo管理员并授权
docker exec -it f0158677e147 mongo admin
db.createUser({ user: ‘admin‘, pwd: ‘n4c1pu46oq‘, roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
db.auth("admin","n4c1pu46oq");
exit