How to Speed up Docker Development! 🐳 Hot Reloading, Debuggers, and More!

Ғылым және технология

Docker is a powerful tool for building and deploying applications, but when getting started, development can be slow and frustrating... 😡
In this video use a node.js (express.js) API application and show how to improve the development experience by:
1) Enable hot reloading with nodemon and volume mounts
2) Configure the node debugger to work from inside the container
3) Set up docker-compose to encode all of the necessary configuration for development
---
Timestamps:
00:00 - Intro
00:53 - Sample app overview
01:24 - Build + run
02:20 - Rebuilding image to make change
03:38 - Setting up nodemon + volume mounts
06:20 - Setting up inspect debugger
08:07 - Demonstrating debugger usage
09:16 - Defining docker-compose.yaml
---
Join the Community:
💬 Discord: / discord
💻 GitHub: github.com/sidpalas/devops-di...
🐥 Twitter: / sidpalas
👨‍💼 LinkedIn: / sid-palas
🌐 Website: devopsdirective.com
---
Community size at time of posting:
- Subscribers: 15680
- Channel Views: 477078

Пікірлер: 100

  • @slinco65
    @slinco652 жыл бұрын

    Boom! Just what I was looking for. Clear and concise. Thanks man 😃

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Thanks, @Simon -- I'm glad it helped! 🎉

  • @CritiKaster
    @CritiKaster2 жыл бұрын

    I love how you break everything down to understandable elements in your videos!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Thank you for the kind words! 🎉

  • @ionitaa

    @ionitaa

    Жыл бұрын

    I love how he's not covering other aspects that even a todo app might have like: - typescript - source mapping and debugging typescript - connecting to a database - connecting to another service

  • @aram5642
    @aram56422 жыл бұрын

    Ohhh man, you are a godsend!!! The only docker hot-reload tutorial that really works - by simply breaking the linkage between node_modules and installing nodemon globally in the container! I still have some other problems, but at least you got me working. You made my day, honestly. Sub.

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Awesome -- glad to have helped! 🎉

  • @aram5642

    @aram5642

    2 жыл бұрын

    @@DevOpsDirective ...although I don't quite get it, why we need to break the linkage of node_modules in volumes:, if we have node_modules in dockerignore

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    @@aram5642 .dockerignore will prevent them from being copied in during the build process but they would still get mounted in with the volume mount of my source directory (to enable hot reloading).

  • @jaxuys
    @jaxuys2 жыл бұрын

    Great video! Thank you for making this, super clear!

  • @LifestyleLogger
    @LifestyleLogger2 жыл бұрын

    Brilliant docker tips, nice and to the point! Thank you 👍

  • @parttimelarry
    @parttimelarry2 жыл бұрын

    Solid tutorial, very clear. Didn’t know how to use the debugger like this.

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Thanks Larry! The --inspect switch can be used without containers too and by default it will bind to 127.0.0.1:9229 on your host.

  • @luthfi9779
    @luthfi9779 Жыл бұрын

    Thank you for the explanation, this is what I'm looking for!

  • @harbingerization
    @harbingerization Жыл бұрын

    Oh my god thank you so much! I spent all day yesterday on SO trying to find the right parameter to pass in for the volume. This explanation was so much easier to follow, and I feel like I have a better idea of how docker works in general.

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    Awesome -- currently working on a multi-hour docker deep dive course due out next month! Stay tuned!

  • @harbingerization

    @harbingerization

    Жыл бұрын

    @@DevOpsDirective oh sweet! Ya I’ll hang out for that!

  • @alleandromurrieta2366

    @alleandromurrieta2366

    Жыл бұрын

    is it work on Windows 11?

  • @jcsoftdev
    @jcsoftdev Жыл бұрын

    I'm new with Docker, but this tutorial was excelent. Thank you so much

  • @notcompletelyinsane
    @notcompletelyinsane Жыл бұрын

    Great stuff! Pretty much exactly what I was looking for and even more.

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    Awesome!

  • @mikopiko
    @mikopiko2 жыл бұрын

    This got to be your best video so far, I visit it sometimes just to refresh my mind. May I ask your thoughts on daemonless container engines like podman?

  • @alexIVMKD
    @alexIVMKD2 жыл бұрын

    Just saw your video on the Traversy Media channel. It was very good!

  • @douglasbrandao391
    @douglasbrandao3912 жыл бұрын

    thats just gold, dude! congrats

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    🏅🙏🎉

  • @evgenisakhatsky612
    @evgenisakhatsky6122 жыл бұрын

    Man!! That's beautiful!

  • @moseskamau4989
    @moseskamau49892 жыл бұрын

    Its like you understood my problem! Thanks!

  • @funkylosik
    @funkylosik2 жыл бұрын

    Playing with docker. Was frustrated with parameters in "docker run", so thanks for showing docker compose ;)

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Yeah it is nice to have all of the configuration encoded in the one file!

  • @secret-alias
    @secret-alias Жыл бұрын

    Very nicely explained! Your video was easy to follow and is definitely something I can begin to use in my own work moving forward as I begin to dockerize! 👍 +1 Subscriber

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    Awesome! Welcome to the Team, Shea! 🤝

  • @alichamas63
    @alichamas632 жыл бұрын

    Awesome man thanks, exactly what I was searching for. Liked and sub'd!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Awesome, thank you!

  • @PkmmteXeleon
    @PkmmteXeleon2 жыл бұрын

    Thank you for this. You’re awesome!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    You are welcome, @PkmmteXeleon! 🎉

  • @ewliang
    @ewliang Жыл бұрын

    Nice. Managed to get my project to hot reload (still needed to hit the refresh button on my browser though sadly) once I changed my nodemon run command to nodemon --legacy-watch. Now if only Docker Desktop's beta feature of "Dev Environments" can work properly... 😅

  • @oscarmoralesgarcia
    @oscarmoralesgarcia Жыл бұрын

    Nice video !!

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    Thank you! Cheers!

  • @evgenisakhatsky612
    @evgenisakhatsky6122 жыл бұрын

    Thank you! Subscribed!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    🎉🎉🎉

  • @SergioUkrAr
    @SergioUkrAr2 жыл бұрын

    Thanks, and for angular?, can I use nodemon? for hot reloading.

  • @hoschiandre
    @hoschiandre2 жыл бұрын

    Great Video ... just a quick question ... do you have for prod a different compose/docker file or how do you handle staging? Thanks for a quick response. Cheers!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Yes, if you are using docker-compose to deploy you would want to have other file(s) containing the appropriate settings, ports, env vars, etc... for staging/prod. If you are deploying via a container orchestrator (such as Kubernetes) those settings would be encoded in your deployment config files.

  • @in-housecoding4360
    @in-housecoding43602 жыл бұрын

    how to run tests like unit tests, integration tests inside docker containers using jest ?

  • @mohdsahil226
    @mohdsahil226 Жыл бұрын

    Could you please help me how to set it up with Kubernetes with Skaffold?

  • @sonvu7896
    @sonvu7896 Жыл бұрын

    immediately hit subscribe after watching your video!

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    🤝

  • @232techtalk
    @232techtalk2 жыл бұрын

    I did everything as it is done on the video but the hot reload does not work. Am I missing something?? I installed nodemon in the container using this command: RUN npm install -g nodemon

  • @lgmsampaio
    @lgmsampaio2 жыл бұрын

    Question: adding node_modules to the .dockerignore woulndn't have the same effect than binding it to a "empty" path as you did?

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Placing node_modules in .dockerignore prevents them from being copied in when the image is built, but I dont think it has an effect on whether or not that directory can be mounted in as a volume. This is why I still needed to bind mount it to an empty volume so those local files wouldn't be mounted in when I mount the source. I could be wrong, but that is my understanding. Feel free to point me to the docs if this is not correct!

  • @FreyClante
    @FreyClante2 жыл бұрын

    Hi DevOps Directive - Thanks for this video, but I'm really struggling to get a React/Typescript dockerized app work with hot reload. Do you have a good resource for this case, or can you make a short video on how to deal with that as well?

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    I haven't looked at it too closely, but this looks like it might be useful medium.com/bb-tutorials-and-thoughts/dockerizing-react-app-with-nodejs-backend-typescript-version-55a40389b0ac

  • @GabrielPerinazzo
    @GabrielPerinazzo2 ай бұрын

    Hey Sir, hope you're fine. May I ask you a question? What if I install a dependency, should I always rebuild the container?

  • @alleandromurrieta2366
    @alleandromurrieta2366 Жыл бұрын

    hi Bro, I need somehelp, I've spend my day to figure it out, but on my Windows 11 its does not work..

  • @389_ayushmaurya8
    @389_ayushmaurya83 ай бұрын

    Hi sir, i am looking for hot reload container for spring bot application please can you share any resources or can create a separate video please

  • @MrDroig
    @MrDroig2 жыл бұрын

    Thaaanks!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    You're weeelcome!

  • @lucasgallardo7603
    @lucasgallardo7603 Жыл бұрын

    Thanks!

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    You’re welcome, Lucas!

  • @imalkrulez
    @imalkrulez2 жыл бұрын

    If we don't mount the node modules also at 5:14 wouldn't we have to rebuild the image when we install a new dependency?

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Yes, you will have to rebuild when installing new dependencies.

  • @niteshrawat736
    @niteshrawat736 Жыл бұрын

    Hi, can we use dockerignore for ignoring node_modules during volume mount?

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    Yes! That is a better solution I forgot about while filming this

  • @mikopiko
    @mikopiko2 жыл бұрын

    Beautiful!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Thank you! Where from Tennessee? I'm from NC

  • @mikopiko

    @mikopiko

    2 жыл бұрын

    @@DevOpsDirective Nashville!

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    @@mikopiko Nice!

  • @pythonBlender7
    @pythonBlender72 жыл бұрын

    Don't use compose its a crutch that will bite you later on when you need to do something more complex. Just take that run command stick it in a bash script. Its just as fast and way more extensible for the future

  • @keemkorn

    @keemkorn

    8 ай бұрын

    Do something more complex like what

  • @ritik84629
    @ritik846292 жыл бұрын

    Nice video! But we don't need the second volume command as it does not copy node_modules folder. Inspect it using docker exec sh command. And we need to add -L in package.json after nodemon for lagacy commands

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    I believe this depends if you have node_modules in the .dockerignore file. I didn't have a .dockerignore file set up in the video making the second mount necessary in that case

  • @jakub7048
    @jakub70486 ай бұрын

    How come that you didn't need to use --legacy-watch flag for nodemon?

  • @danishmaqsood9969
    @danishmaqsood99692 жыл бұрын

    Sir i am working in fastapi which module i am install in docker file instead nodemon

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    I havent really used fastapi, but from the docs fastapi.tiangolo.com/#run-it It looks like you would want to run with a command like: uvicorn main:app --reload

  • @arrozinsano7154
    @arrozinsano71542 жыл бұрын

    thanks man

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    You are welcome!

  • @pramodteegulla917
    @pramodteegulla9172 жыл бұрын

    Thankyou 🙏🏽

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    You are welcome, @pramod!

  • @kishorrathva4097
    @kishorrathva40972 жыл бұрын

    Thank you

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    You are welcome @Kishor! 🙏

  • @i3130002
    @i3130002 Жыл бұрын

    It creates a persistance node_module volume so it gets dirty :|

  • @DominikGuzowski
    @DominikGuzowski2 жыл бұрын

    Any ideas why nodemon still doesnt reload? I rewatched the video like 5 times by now

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Tough to say without seeing the code... If I had to take a guess though, I would go with a problem with the volume mount such that the changes on your host filesystem are not being reflected in the container

  • @DominikGuzowski

    @DominikGuzowski

    2 жыл бұрын

    @@DevOpsDirective so I actually figured it out, the nodemon command didn't seem to act the way it usually does without docker, so I had to specify for it to watch the src folder with nodemon -L --watch src ...

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    I'm glad you were able to figure it out! Nice work!

  • @byambaoyungerel9795
    @byambaoyungerel97952 жыл бұрын

    Bless

  • @TheJFMR
    @TheJFMR2 жыл бұрын

    Hello! Nice tutorial, I am trying to connect this with a MariaDB database (another service in the docker-compose) and I can't.

  • @YurleyLopez-tw8lw
    @YurleyLopez-tw8lw9 ай бұрын

    ❤❤❤

  • @nash494
    @nash4942 жыл бұрын

    What if we decide to add a new dependency ?

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Good question! Whenever you add/change a dependency you need to rerun `docker build` to get those installed into the container image

  • @nash494

    @nash494

    2 жыл бұрын

    @@DevOpsDirective Thanks, appreciate the fast response!

  • @atikalove9
    @atikalove92 жыл бұрын

    Nice vidéo.. I came from traversty media.. Brad's channel

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    Awesome, welcome to the team! 😀

  • @atikalove9

    @atikalove9

    2 жыл бұрын

    @@DevOpsDirective thanks. One question. I am completely new to all these, programming, scripting, coding and softwares in general. Do I need any foundation before becoming a DevOps engineer?

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    I think it is useful to build a foundation in either development or operations before transitioning to DevOps. It's not impossible to jump straight in, but having a foundation in one side or the other makes it much easier!

  • @atikalove9

    @atikalove9

    2 жыл бұрын

    @@DevOpsDirective thanks for the advice.. I should probably start from development..

  • @anil_7737
    @anil_7737 Жыл бұрын

    What is your name bro?

  • @DevOpsDirective

    @DevOpsDirective

    Жыл бұрын

    ?… I say it 30 seconds into the video 😅

  • @giannifed
    @giannifed2 жыл бұрын

    Thank you

  • @DevOpsDirective

    @DevOpsDirective

    2 жыл бұрын

    You're welcome @Gianni!

Келесі