MongoDB server boilerplate using Docker compose, with Mongo Express as management server
Run docker-compose up
.
- Run
docker exec -it mongo mongo
- Run
use admin
to select the admin DB. - Run
db.auth('root', 'example')
to log on using the admin credential (root:example) - Run create user command:
db.createUser( {user: "avinshum", pwd: "pwd", roles: [ { role: "readWrite", db: "db"}]})
. Note that the command restricts the new user to access the DBdb
only.
-
It is useful if you have set a wrong admin password and want to start over. It usually happens at the early stage.
Run
docker-compose rm -fv [SERVICE...]
- Run
docker volume ls
- Run
docker volume prune