sudo docker run -p 27017:27017 --name some-mongo -d mongo --auth
This will download the official mongo
Docker image and run it in detached mode with auth turned on.
sudo docker exec -it some-mongo bash
you should get a bash terminal inside the container, like
root@093275de44e7:/#
mongo admin
you should get a mongo shell like
(some message)
>
db.createUser({user: 'admin', pwd: 'password', roles:[{role: 'root', db: 'admin'}] })
The username and password can be changed here to your own choice.
After this you should see a message like
Successfully added user: {
"user" : "admin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
> exit
mongo -u admin -p password --authenticationDatabase admin
If successful, you should get a new mongo shell like
(some message)
>
> use testdb
db.createUser({user: 'sirius', pwd: 'valis', roles:[{role: 'readWrite', db: 'testdb'}, {role: 'readWrite', db:'database'}, {role: 'readWrite', db:'database1'}, {role: 'readWrite', db:'userdb'}, {role: 'readWrite', db:'analysisdb'}] })
After this step, you should see another Successfully added user
message, and your MongoDB container is ready to go!
Note: Here the MongoDB does not have any data yet. We will first run SIRIUS in a docker image in the next step, then upload data in there.