How to dockerize NodeJS and MongoDB application using docker-compose

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • 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: github.com/trulymittal/Nodejs...
    Install Docker: • Install Docker on Windows
    Docker Playlist: • Docker
    --------------------------------------------------------------------------
    📦FREE $100 credit @Digital Ocean: m.do.co/c/3208f08b3324
    --------------------------------------------------------------------------
    Subscribe: czcams.com/users/yourstruly2...
    --------------------------------------------------------------------------
    💵Support the channel:
    Paypal: www.paypal.me/trulymittal
    Patreon: / 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! www.kite.com/get-kite/?...
    --------------------------------------------------------------------------
    ======================
    ✔ Other useful Playlists
    ======================
    #RestAPI (#NodeJS and MongoDB): • REST API using NodeJS ...
    #API Authentication using #JWT: • NodeJS API Authenticat...
    #Firebase: • Firebase | Build a Not...
    Docker: • Docker
    MongoDB: • Learn MongoDB in 50 mi...
    Html/Css/Js: • HTML / CSS / JS
    Android: • Android
    Challenges: • Challenges
    #yoursTRULY #tutorial #howto #nodejs #android

Komentáře • 96

  • @chrisorescan2733
    @chrisorescan2733 Před 2 lety +11

    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.

  • @nomanshahid667
    @nomanshahid667 Před rokem

    I was working on flask (python) restful api with mongodb and none of the flask + docker tutorials I watched had worked. I decided to give this one a go and it worked like a charm. Thank you so much

  • @leiayuri
    @leiayuri Před 2 lety

    Man, Thanks for that. It was really useful. Simple however straight to the important points.

  • @jonee4468
    @jonee4468 Před 11 měsíci

    Thank you for creating such an informative and easy-to-understand video on Docker. I was confused about its use and how to learn it, but this video cleared up all my doubts. Keep up the great work! 😊

  • @clamgts
    @clamgts Před 2 lety +1

    Thank you, this tutorial was absolutely perfect.

  • @faysalahmed2619
    @faysalahmed2619 Před 9 měsíci

    Thank you man, for providing such a clear and straightforward tutorial

  • @pasindushavinda4455
    @pasindushavinda4455 Před rokem +1

    Really Informative Explenation !! Great JOB !! Thank You !! 👏

  • @paragbharadva6018
    @paragbharadva6018 Před 2 lety

    Explored very straight forward....
    Loved it.... ❤️

  • @itsivar
    @itsivar Před rokem

    Awesome video, well explained.
    Thanks!!

  • @sammed.sankonatti
    @sammed.sankonatti Před 6 měsíci +2

    Crisp and clear explanation ✨. It Solved some of my doubts 🙌

  • @stevenjchang
    @stevenjchang Před 2 lety +6

    WOW, you are SO GOOD at teaching! You really understand the balance of how to give a good pace, while stopping to give explanations when needed.
    Most coding tutorials don't understand the balance. They either explain every little thing, making the video super slow (and sometimes skipping an important explanation), or they just show a demo of them coding a project and don't explain anything.
    I felt like you explained everything I wanted to know, and skipped everything I didn't.

  • @vishal-shinde
    @vishal-shinde Před 10 měsíci

    this was a great tutorial. I have my nodejs and mongo project which I wanted to dockerize. thanks!

  • @narekmusakhanyan523
    @narekmusakhanyan523 Před 9 měsíci

    You did a great job, thank you!

  • @theprocoder01
    @theprocoder01 Před 2 lety +1

    Amazing tutorial.
    The only tutorial which worked for me, many thanks. Keep it up

    • @mafiacodes
      @mafiacodes  Před 2 lety

      Glad to hear that
      Subscribe like share

  • @divisorZero
    @divisorZero Před 6 měsíci

    Thank you, Bro! Very informative tutor! It helps me to start!

  • @AjaySharma-vz9ei
    @AjaySharma-vz9ei Před rokem +1

    Thank you so much for this awesome Content 🙏🏻

  • @aram5642
    @aram5642 Před 2 lety +3

    That is a heck of a good tutorial. I hope you will extend it by migrating api to typescript - then there will be an additional build step.

  • @sinaukode
    @sinaukode Před 2 lety +2

    Really big thanks to you, how you explain every concept is so nice

    • @mafiacodes
      @mafiacodes  Před 2 lety

      Thanks and welcome
      Subscribe like share

  • @userr4693
    @userr4693 Před 2 lety +1

    Thank you for making it easy

  • @tatianalezhneva9100
    @tatianalezhneva9100 Před 2 lety +2

    You just saved another 2 hours of my life. Thanks!!!

  • @AminulislamSakib
    @AminulislamSakib Před rokem +1

    Thank you. It was so helpful

  • @shubhamdixit7909
    @shubhamdixit7909 Před rokem

    This is a great one mahn!!

  • @eL3M3nT4LisT
    @eL3M3nT4LisT Před 8 měsíci

    You saved my life with docker and nodejs tech

  • @contactpbs2058
    @contactpbs2058 Před 2 lety

    Great conceptual thank you so much sir

  • @Asanka-tc3oh
    @Asanka-tc3oh Před 6 měsíci

    Thank you very much. very descriptive content

  • @tiekkale
    @tiekkale Před rokem +1

    Excellent Tutorial

  • @andsyahr
    @andsyahr Před 10 měsíci

    very nice, it help me a lot

  • @diaaelrahman2410
    @diaaelrahman2410 Před 12 dny

    You are the best thank you!

  • @paulnaija
    @paulnaija Před rokem +1

    I was just at 9:54 mins before i subscribed to your channel.... You are very detailed and perfect at teaching... This was very helpful, Thank you.

  • @subhashgn1775
    @subhashgn1775 Před rokem

    Great tutorial.👌👌

  • @TheJavituber
    @TheJavituber Před 11 měsíci

    Gracias señor Hindú, me ayudó a salvar el semestre

  • @vishwanathnijampurkar9862

    great video pls keep making this kind of new videos

  • @thongtranlequoc688
    @thongtranlequoc688 Před rokem +1

    Thank you so much bro! Your video so good!

  • @techabl
    @techabl Před rokem +1

    Great thanks 👍

  • @replyishwor
    @replyishwor Před 8 měsíci

    thank you brother

  • @ramiworkstation
    @ramiworkstation Před měsícem

    Thank you 🙏

  • @naveenkumarmurugan1962
    @naveenkumarmurugan1962 Před 10 měsíci

    You are the best

  • @usmanmughal5916
    @usmanmughal5916 Před 2 lety +5

    Make a video on kurbernetes load balancer with ingress ngnix react,node,database

  • @kiranojha7820
    @kiranojha7820 Před 2 lety +1

    Amazing tutorial. Can you tell me the theme and font you're using? It's really pleasing for me

  • @arvindnathrajesh255
    @arvindnathrajesh255 Před 2 lety

    crazy brother. u r god

  • @be_b_50_ankitkumar_singh79

    Was needed

  • @mirzabicer3896
    @mirzabicer3896 Před 2 lety

    Thank you

  • @KaioRodrigues-nv9sp
    @KaioRodrigues-nv9sp Před rokem +1

    Awesome !!11

  • @muhammadmursalin8915
    @muhammadmursalin8915 Před 2 lety +1

    Great 👍👌

  • @Cristutz00
    @Cristutz00 Před rokem +1

    13:20 ci stands for Clean Install

  • @jonee4468
    @jonee4468 Před 11 měsíci

    can you please make a tutorial on How to use the same Dockerfile for both local development and production with multi-stage builds?

  • @hassanebendaoud4446
    @hassanebendaoud4446 Před 2 lety

    thanks

  • @vishwanathnijampurkar9862

    Please make video on how to manage vulnerability errors

  • @amir-ali8850
    @amir-ali8850 Před 6 měsíci +1

    could you tell what themes and fonts you are using?

  • @AbdulAlim-zg8vt
    @AbdulAlim-zg8vt Před 2 lety

    Can you please share the example files?

  • @harshyadav6097
    @harshyadav6097 Před 11 měsíci +1

    best

  • @youmee8956
    @youmee8956 Před 2 lety

    Hello sir been waiting for your video so long. But im here just to remind you any plan to release new series of rock solid on how to avoid zero downtime when redeploy the app. don't mind me♥️😊

  • @contactpbs2058
    @contactpbs2058 Před 2 lety

    Please do a video on Microservices Node js

  • @Templestepscom
    @Templestepscom Před 9 měsíci

    npm ci - ci stand for clean install

  • @markopavlovic6066
    @markopavlovic6066 Před rokem

    Hello, i want my mongodb container to use data from local db how can i do that?

  • @md.abuhusna9666
    @md.abuhusna9666 Před rokem

    Would you please share the font family name you are using ?

  • @webcoder293
    @webcoder293 Před 11 měsíci

    If I have already a db in Mongodb atlas and I wanna use it inside container, then what would be the Mongo env variables. And where to mention that - docker-compose.yml or Dockerfile?

  • @swejalshrestha4744
    @swejalshrestha4744 Před 2 lety

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

  • @riteshthakur9250
    @riteshthakur9250 Před 2 lety

    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.

  • @user-ek1sj4dp2k
    @user-ek1sj4dp2k Před 9 měsíci

    If my database is in mongodb atlas, then what different steps should i follow......( like you changed localhost name to mongodb , so i am asking)

  • @VarunDeva23
    @VarunDeva23 Před 2 lety

    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

  • @kostaskaldis9285
    @kostaskaldis9285 Před 2 lety

    nodemon part is not working for my case

  • @srinuannamneedi6458
    @srinuannamneedi6458 Před 2 lety

    I have cloned the repo and followed the steps as u mentioned , but getting this error " Mongoose connection is disconnected..."

  • @codewithsub5083
    @codewithsub5083 Před rokem +2

    Your VS code configuration looks very good.
    Can you please share the configuration?
    Thank you

  • @randrianantenainanambinint9686

    Good content but i have problem, when i consult my api logs, i have that:
    > NODE_ENV=DEVELOPMENT nodemon app.js
    sh: nodemon: Permission denied

  • @yosepmys7605
    @yosepmys7605 Před 2 lety

    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.

    • @yosepmys7605
      @yosepmys7605 Před 2 lety

      So I clone the code from git, and there was different in app.js route. After I add get(‘/‘) it works! But why nodemon not working with yours? I add volumes to include node_modules and it works.

  • @ahmedhafez9951
    @ahmedhafez9951 Před 11 měsíci

    ♥♥♥

  • @digvijaysinghthakur2903
    @digvijaysinghthakur2903 Před 2 lety +2

    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?

    • @mafiacodes
      @mafiacodes  Před 2 lety

      Yes 💯%

    • @abhiramsatpute
      @abhiramsatpute Před rokem

      @@mafiacodes if possible PIN this comment as well, this doubt will come to many

    • @vinosamari
      @vinosamari Před rokem

      @@abhiramsatpute There are still use cases for running locally so having the atlas url doesn't invalidate this method.

  • @suryavamsi5031
    @suryavamsi5031 Před rokem

    Server started on port 3000...
    nodejs-rest-api-nodejs-1 | Mongoose connection is disconnected...
    nodejs-rest-api-nodejs-1 | Server selection timed out after 30000 ms
    nodejs-rest-api-nodejs-1 | Server selection timed out after 30000 ms,
    I'm getting this error, could any help me out...

  • @lukachannel12
    @lukachannel12 Před 2 lety +1

    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!

    • @OneEyedGhost
      @OneEyedGhost Před 2 lety

      Hey I am also doing the same and got the error before i added the env variables in the dockerfile. Hope it helps!!

    • @kiranojha8811
      @kiranojha8811 Před 2 lety

      you need to add env inside docker compose

  • @milon27
    @milon27 Před 2 lety +1

    please make a part 2 of it. deploy it on digital ocean Ubuntu server

    • @milon27
      @milon27 Před 2 lety +2

      part 3: show ci/cd using GitHub action

  • @jinnybat
    @jinnybat Před rokem

    I cannot connect to mongoDb with db name or container name however it is getting created and connected with localhost only, am I missing something?

  • @mahitoshgiri5879
    @mahitoshgiri5879 Před 22 dny

    😊

  • @mufeezahmedmohammad9441

    Wow

  • @rbnby
    @rbnby Před 2 lety

    I miss your android tutorial

  • @user-gi9oj9iz5r
    @user-gi9oj9iz5r Před rokem

    For anyone getting an error 404 not found, add this above the const productRoute.... (it's not on the githubrepo)
    app.get('/', (req, res, next) => {
    res.json({ message:'It works .', env_name: process.env.NAME})
    })