<p>I've a backend application running on node and mongodb. I wanted to shift my application to docker so I've dockerized node but I'm confused where should I run mongodb or should I dockerize it or not.</p>
<p><strong>Note: I want to do this for production environment</strong></p>
<p>Here are some scenarios, I've thought of:</p>
<ol>
<li>Run node in docker container and mongodb in local machine</li>
<li>Run both node and database in docker containers and store the data in the container same as database</li>
<li>Run node and database in docker containers and store the data in separate volume</li>
</ol>
<p><strong>Which scenario is the best to implement on production server?</strong></p>
<p><em>I'm new to docker so <strong>if you have other solution to this problem, consider mentioning it.</strong> Also you can involve <strong>kubernetes</strong> in the scenarios if needed</em></p>

Abhishek Pankar
<p>You can use one of this two solution:</p>
<ul>
<li><p>Create a deployment for your node js server and use a local mongodb , connection estabilished via your host ip (but this only valide for developement ) . To use this solution for production you should create and setup a public @ip address to esure the TCP connection between mongo and node js app .</p>
</li>
<li><p>The Second solution is to create a deployment for your node js server and a statfulset for your mongodb database and use (pv,pvc,storageclasse) to persist your data .</p>
</li>
</ul>
<p>I have a demo using mongo ,redis and nodejs (express app) that you can follow to resolve your issue
Follow my example <a href="https://github.com/radhouen/products-store" rel="nofollow noreferrer">here</a>.</p>
