Setting up a MongoDB service


MongoDB is a popular and open-source NoSQL database that can run in your Docker environment on MedStack Control. At the moment, we do not offer a managed service for MongoDB as we do with PostgreSQL and MySQL.

How to set up a MongoDB service

You can create a MongoDB service in your Docker environment using the public image for this service as made available on Docker Hub. Here is how we recommend you set up the MongoDB service in Docker:

  1. Add a label to the node you'd like to pin the stateful service (MongoDB) to run on. Docker Swarm doesn't support persistent volume claims across the nodes in the Docker environment, so you need to configure a stateful service to be pinned to a specific node to ensure the data does not fragment across different node disks. Note, Docker is adding persistent volume claims to Swarm later this year which will fix the need for this configuration.
  2. Create a volume mapping for the Docker environment to enable the storage and backup of the database per our automatic backup system.
  3. Create a new service using the image "mongo:{tag}" where you specify the tag/version that you'd like to deploy (avoid using the :latest tag in case a breaking change is introduced).
  4. Configure the service with the volume mapping and add a placement constraint to pin the service to the node with the label specified in step (1).

Going through these steps should get you set up with a MongoDB running in the Docker environment and makes use of our hourly backup system. See more on our article discussing the pros and cons of running a database in Docker vs managed database service.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Submit a request for support Submit a request for support