Dockerize MERN Full Stack App Part 1(Node.js and MongoDB)

Ali Alhaddad
7 min readMay 10, 2022
Photo by Rubaitul Azad on Unsplash

We will be dockerizing an existent mern application.

What does dockerizing or dockerize mean? We will be converting a full stack app that runs locally to an app that you run in a container that can be deployed.

Each container will be responsible for one part of the application. It’s best practice that each container is responsible for one part of your application, in complex circumstances such as microservices, you would have a container for each microservice. But in this case our containers would be setup like this.

  • One Container for the Database.
  • One Container for the Backend.
  • One Container for the Frontend.

What is docker?

  • It is a open source platform for developing, shipping and running applications.
  • Allows to use a isolated environment to run applications.
  • This isolated environment allows you to run a multitude of tools without needing it to install it on your local machine.

First install docker.

Make sure you configure linux containers on windows(if you are on windows) via WSL2.
If you are on mac or linux, you don’t have to worry about this.

Install postman for testing your server.

Clone these two repositories to dockerize.

This is the node.js app