Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. # Get the image from hub and start the container with authentication enabled
  3. 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
  4. # Enter into the container to set user roles/access on specific DB
  5. docker exec -it mongo-container bash
  6. # Login into admin DB (default) as admin user
  7. mongo -u "admin" -p "admin" admin
  8. # Create a new DB
  9. use iams_file_dev
  10. # Create user and set access to the specific DB
  11. db.createUser({user: "admin", pwd:"admin", roles:[{"role":"readWrite", "db":"iams_file_dev"}]})
  12. # Quit
  13. quit()
  14. # Login into the desired DB
  15. mongo -u "admin" -p "admin" iams_file_dev
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement