1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| docker run -itd --name attack-i-mongo -v /Users/attacki/mongo:/data/db -v /Users/attacki/mongo/db_config/mongo.conf:/data/configdb/mongo.conf -p 27037:27037 -d mongo -f /data/configdb/mongo.conf
docker exec -it attack-i-mongo mongo --host 127.0.0.1 --port 27037 admin
use admin
db.createUser({user:'root',pwd:'root',roles:['root']}) db.createUser({ user: 'admin', pwd: 'admin', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
db.auth('admin','admin')
db.createUser({ user: "attack-i", pwd: "attack-i", roles: [ { role: "readWrite", db: "attack-i" } ] });
|