Execute the following command to pull the Mongo image:
docker pull mongo:3.4.3
Create a folder dedicated to Mongo:
/storage/mongo/data
//First grant permissions
chcon -Rt svirt_sandbox_file_t /storage/mongo/data
Execute the following command to start MongoDB:
docker run --name mongo-test -d -p 27017:27017 -v /storage/mongo/data:/data/db mongo:3.4.3 --auth
Next, we need to enter the container's command line to create a username and password:
//Create an administrator
db.createUser({user:'mongo_admin',pwd:'mongo_admin',roles:[{role:"userAdminAnyDatabase",db:"admin"}]});
//Log in as admin
db.auth('mongo_admin','mongo_admin')
//Create and switch database
use test
//Create user, assign permissions
db.createUser({user:"mongo_test",pwd:"mongo_test",roles:[{role:"dbOwner",db:"test"}]})