Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 926 Bytes

README.md

File metadata and controls

44 lines (28 loc) · 926 Bytes

Dockerizing the Application 🐳

This project is an example of a Dockerized MERN stack application, making it easy to build and run the application in a container.

Build the Docker image

To build your Docker image, run the following command:

docker build -t mern-app .

Run the Docker container with environment variables:

Use the following command to run the Docker container while passing environment variables for MongoDB Atlas and any other configuration:

docker run -p 3001:3001 \
-e MONGO_URI="mongodb+srv://<username>:<password>@cluster0.mongodb.net/<dbname>?retryWrites=true&w=majority" \
-e NODE_ENV=production \
mern-app

Stopping the container:

To stop the running container, first list the running containers:

docker ps

Then stop the container using its container ID:

docker stop <container_id>