Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get the image from hub and start the container with authentication enabled
- docker run -d --name mongo-container -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin mongo:3.6 mongod --auth
-
- # Enter into the container to set user roles/access on specific DB
- docker exec -it mongo-container bash
-
- # Login into admin DB (default) as admin user
- mongo -u "admin" -p "admin" admin
-
- # Create a new DB
- use iams_file_dev
-
- # Create user and set access to the specific DB
- db.createUser({user: "admin", pwd:"admin", roles:[{"role":"readWrite", "db":"iams_file_dev"}]})
-
- # Quit
- quit()
-
- # Login into the desired DB
- mongo -u "admin" -p "admin" iams_file_dev
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement