Run Mongo from a docker

To create the container:

docker run --name mongo -v /home/core/mongo-files/data:/data/db -v /home/core/mongo-files:/opt/keyfile --hostname="node1.example.com" -p 27017:27017 -d mongo:2.6.5 --smallfiles

(remember to change 2.6.5 with the version you want to use)

To run the container:

docker start mongo

For accessing Mongo terminal:

docker exec -it [NameOfTheContainer] mongo

Therefore, in this case:

docker exec -it mongo mongo

More information here and in the official Docker image documentation. This script example is also interesting.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.