Lessons

Deploy MongoDB on Render

In this tutorial, we will deploy a MongoDB instance to Render. As of September 2023, Render doesn’t support a managed instance of Mongo. If you want to use the Render Blueprint, use this link.

For this tutorial, you will require Github and Render. Start by creating a new Github repository.

Screenshot 2023-09-05 at 12.42.10 PM.png

We are going to use this template. We are only copying the Dockerfile. Here is the content of the Dockerfile.

1 FROM mongo:4.2

Push the Dockerfile to your remote branch.

1 2 3 git add --all git commit -m "Dockerfile" git push

Navigate to your Render account. In the top navbar, hit “New”. Then select “Private Service”. This will mean our service won’t be accessible from the public internet. Only services that are in the same Region and Hosted on Render will be able to access it.

Screenshot 2023-09-05 at 12.45.59 PM.png

Select the repository, and hit “Connect”.

Screenshot 2023-09-05 at 12.47.57 PM.png

Create a name for the service. Select the “Docker” under the Runtime.

Screenshot 2023-09-05 at 12.50.27 PM.png

Then click “Advance”, and add a Disk. You can change the disk size to whatever you want.

Screenshot 2023-09-05 at 12.51.01 PM.png

Once you are set with all fields, then hit “Create Private Service”.

Your new service will spin up.

Screenshot 2023-09-05 at 1.01.35 PM.png

You can see the “service address” to connect to your DB.

You can test the connection by navigating to “Shell”. You can connect:

1 mongo --host demo-render-mongodb

Replace “demo-render-mongodb” with your service address (no port). You can exit with

1 quit()

That’s it! You are setup on Render with MongoDB.

References

On This Page