How to dockerize NodeJS and MongoDB application using docker-compose



In this video we will learn how to use #docker-compose to containerize a #Nodejs #express with #MongoDB as a database.

Chapters:
Introduction 0:00
Description of Example Repo: 0:31
Dockerizing basics: 5:46
Files needed for docker compose: 7:07
Dockerfile for Nodejs application: 9:42
Bonus (npm ci) continuous integration: 12:42
.dockerignore file: 14:16
docker-compose: 16:48
MongoDB container (service): 18:12
Nodejs container (service): 21:57
Volume for MongoDB: 27:31
Starting container (docker compose up): 28:34
Port mapping for Mongodb: 34:24
Developing using #Nodemon: 36:46
Bonus (#Redis container): 41:25

Github link of repo used: https://github.com/trulymittal/Nodejs-REST-API
Install Docker: https://youtu.be/GUk_BF-msH0
Docker Playlist: https://www.youtube.com/playlist?list=PLdHg5T0SNpN0gFlL8AXvZdAHsvpkuW0Ba
————————————————————————–
📦FREE $100 credit @Digital Ocean: https://m.do.co/c/3208f08b3324
————————————————————————–
Subscribe: https://www.youtube.com/c/yourstruly267?sub_confirmation=1
————————————————————————–
💵Support the channel:
Paypal: https://www.paypal.me/trulymittal
Patreon: https://www.patreon.com/trulymittal
————————————————————————–
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I’ve been using Kite for 6 months and I love it! https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=yourstruly&utm_content=description-only
————————————————————————–

======================
✔ Other useful Playlists
======================
#RestAPI (#NodeJS and MongoDB): https://www.youtube.com/playlist?list=PLdHg5T0SNpN3EoN3PEyCmPR42Ok_44OFT
#API Authentication using #JWT: https://www.youtube.com/playlist?list=PLdHg5T0SNpN0ygjV4yGXNct25jY_ue70U
#Firebase: https://www.youtube.com/playlist?list=PLdHg5T0SNpN2NimxW3piNqEVBWtXcraz-
Docker: https://www.youtube.com/playlist?list=PLdHg5T0SNpN0gFlL8AXvZdAHsvpkuW0Ba
MongoDB: https://www.youtube.com/watch?v=liocKBCVJyw&t=7s
Html/Css/Js: https://www.youtube.com/playlist?list=PLdHg5T0SNpN0saXVT9gfb2MESkiHG8YbP
Android: https://www.youtube.com/playlist?list=PLdHg5T0SNpN2cv8zhK-zQx2qXfJKap9kU
Challenges: https://www.youtube.com/playlist?list=PLdHg5T0SNpN20F2v0xYWeLRZtdehexzDi

#yoursTRULY #tutorial #howto #nodejs #android

source

21 thoughts on “How to dockerize NodeJS and MongoDB application using docker-compose”
  1. Hii
    I am building a microservice in docker-compose and i want that if any service crashes then it should restart automatically. i used restart tag in compose file but it is not restarting if the service crashes. All of my services in node app. Can you please help me.

  2. I followed the tutorial, however when I do "docker compose up", it gives me an error "MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". It's like the environment varaiables I declared aren't being read properly. I'm using an .env file and it works fine when I run the app outside of a container. I searched online and found no solution. Any tips? Great video btw, helped me a lot, thanks!

  3. Thank you for your tutorial. I following yours, but I’m stuck with 404 status when I access localhost:4000. While status in terminal: nodejs-rest-api-api-1 | Mongodb connected….

    What should I do to find where error(s) came from? TIA.

  4. This was very thorough. After reading many tutorials about setting up Mongo for docker, this is the only one that actually worked. I'm now looking for more details on initializing Mongo database and roles, but this video has proven very useful.

  5. How to backup MongoDb database?
    For time being i want to backup my MongoDb data to my local pc from my Vps server which is digital Ocean droplet.
    After some time I'll create new droplet and restore the database.

    If it's the mysql then i can download .sql file from exporting Through phpmyadmin. Whenever i want i can import .sql file again

    Same thing how to do with docker? For MongoDb

  6. after docker compose up… my node server is working but there is problem in database connection

  7. Can we add Mongodb Atlas URI in place of local MONGODB_URI in api service inside docker-compose but in that case I think we don't need mongodb service because now our database hosted on cloud. Am I right?

Leave a Reply

Your email address will not be published.

Captcha loading...