dockers 部署mongo

镜像加速 阿里云
docker pull registry.cn-hangzhou.aliyuncs.com/wangbs/mongodb

运行mongo
docker run –name mongo_auth -v /dockerDir/mongodb/data:/data/db -p 27018:27017 -d registry.cn-hangzhou.aliyuncs.com/wangbs/mongodb:latest –auth
进入容器
docker exec -it mongo_auth mongo admin

添加用户及角色
$ docker exec -it some-mongo mongo admin
connecting to: admin

db.createUser({ user: ‘jsmith’, pwd: ‘some-initial-password’, roles: [ { role: “userAdminAnyDatabase”, db: “admin” } ] });
Successfully added user: {
“user” : “jsmith”,
“roles” : [
{
“role” : “userAdminAnyDatabase”,
“db” : “admin”
}
]
}

你可能感兴趣的:(CentOS,Docker)