Running Nodejs & MongoDB on the same container/instance?

Posted March 15, 2021 330 views

Hi. I’m new into the world of Docker/Kubernetes (or any container system in general).

I have a NodeJS application (a little CMS) using MongoDB. I want it to be simple to duplicate, configure and customize.

I always hosted my applications on Ubuntu VM, but configuring and doing maintenance is very time consuming.

So I wanted to use the new Digital Ocean App feature to deploy my NodeJS app quickly (and being able to configure and duplicate the same application for multiple clients of mine). But this doesn’t allow me to host my MongoDB database with it (and Digital Ocean doesn’t have MongoDB in his offer, and I don’t want to have it on another host).

So I tried to put my application on Docker, but it seems that digital ocean counts one docker service as a single VM. So I’m unable to have both my NodeJS and MongoDB containers running on the same “server”.

Can Kubernetes can solve this problem or am I doing something wrong?

I don’t really care about performances, instances, microservices and such. My application is simple. If it starts to slow down, I just want to be able to purpose to my client to just buy a better server and do a Digital Ocean API call for it.

Thank you for your help.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Thanks for your question! Using Kubernetes would achieve the goal of having both your nodeJS and MongoDb containers running on a single instance. Here is a tutorial that contains instructions on how to configure this on our platform.


by Kathleen Juell
Kubernetes is a system for running modern, containerized applications at scale. With it, developers can deploy and manage containerized applications across clusters of machines. When creating multi-service deployments with Kubernetes, many developers opt to use the Helm package manager. In this tutorial, you will deploy a replicated Node.js application with a MongoDB database using Helm charts, which will be a good starting point for building other resilient and fault-tolerant applications.