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

Поділитися
Вставка
  • Опубліковано 11 чер 2024
  • 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
    @slinco65 2 роки тому +14

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

  • @CritiKaster
    @CritiKaster 2 роки тому +2

    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

  • @LifestyleLogger
    @LifestyleLogger Рік тому

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

  • @parttimelarry
    @parttimelarry 2 роки тому +1

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

    • @DevOpsDirective
      @DevOpsDirective  2 роки тому +1

      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.

  • @jaxuys
    @jaxuys 2 роки тому

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

  • @aram5642
    @aram5642 2 роки тому +1

    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 роки тому +1

      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 роки тому +1

      @@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).

  • @luthfi9779
    @luthfi9779 Рік тому

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

  • @jcsoftdev
    @jcsoftdev Рік тому

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

  • @mikopiko
    @mikopiko 2 роки тому

    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?

  • @notcompletelyinsane
    @notcompletelyinsane Рік тому

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

  • @alexIVMKD
    @alexIVMKD 2 роки тому

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

  • @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  Рік тому +1

      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?

  • @moseskamau4989
    @moseskamau4989 2 роки тому

    Its like you understood my problem! Thanks!

  • @evgenisakhatsky612
    @evgenisakhatsky612 2 роки тому

    Thank you! Subscribed!

  • @evgenisakhatsky612
    @evgenisakhatsky612 2 роки тому

    Man!! That's beautiful!

  • @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

  • @alichamas63
    @alichamas63 2 роки тому

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

  • @PkmmteXeleon
    @PkmmteXeleon 2 роки тому

    Thank you for this. You’re awesome!

  • @douglasbrandao391
    @douglasbrandao391 2 роки тому

    thats just gold, dude! congrats

  • @funkylosik
    @funkylosik 2 роки тому

    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!

  • @sonvu7896
    @sonvu7896 11 місяців тому

    immediately hit subscribe after watching your video!

  • @oscarmoralesgarcia
    @oscarmoralesgarcia Рік тому

    Nice video !!

  • @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... 😅

  • @hoschiandre
    @hoschiandre 2 роки тому

    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 роки тому +1

      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.

  • @232techtalk
    @232techtalk 2 роки тому +1

    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

  • @pythonBlender7
    @pythonBlender7 2 роки тому +4

    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 6 місяців тому

      Do something more complex like what

  • @SergioUkrAr
    @SergioUkrAr Рік тому

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

  • @GabrielPerinazzo
    @GabrielPerinazzo Місяць тому

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

  • @ritik84629
    @ritik84629 2 роки тому +2

    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 роки тому +1

      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

  • @MrDroig
    @MrDroig 2 роки тому

    Thaaanks!

  • @in-housecoding4360
    @in-housecoding4360 2 роки тому

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

  • @lucasgallardo7603
    @lucasgallardo7603 Рік тому

    Thanks!

  • @mohdsahil226
    @mohdsahil226 Рік тому

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

  • @FreyClante
    @FreyClante 2 роки тому

    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

  • @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_ayushmaurya8 Місяць тому

    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

  • @lgmsampaio
    @lgmsampaio 2 роки тому

    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 роки тому +1

      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!

  • @mikopiko
    @mikopiko 2 роки тому

    Beautiful!

  • @pramodteegulla917
    @pramodteegulla917 2 роки тому

    Thankyou 🙏🏽

  • @imalkrulez
    @imalkrulez 2 роки тому

    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 роки тому +1

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

  • @jakub7048
    @jakub7048 5 місяців тому

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

  • @arrozinsano7154
    @arrozinsano7154 2 роки тому

    thanks man

  • @giannifed
    @giannifed 2 роки тому

    Thank you

  • @niteshrawat736
    @niteshrawat736 Рік тому

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

    • @DevOpsDirective
      @DevOpsDirective  Рік тому +1

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

  • @danishmaqsood9969
    @danishmaqsood9969 2 роки тому

    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

  • @byambaoyungerel9795
    @byambaoyungerel9795 Рік тому

    Bless

  • @YurleyLopez-tw8lw
    @YurleyLopez-tw8lw 8 місяців тому

    ❤❤❤

  • @i3130002
    @i3130002 Рік тому

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

  • @atikalove9
    @atikalove9 2 роки тому

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

    • @DevOpsDirective
      @DevOpsDirective  2 роки тому +1

      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 роки тому +1

      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..

  • @TheJFMR
    @TheJFMR 2 роки тому

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

  • @DominikGuzowski
    @DominikGuzowski 2 роки тому

    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!

  • @nash494
    @nash494 2 роки тому

    What if we decide to add a new dependency ?

    • @DevOpsDirective
      @DevOpsDirective  2 роки тому +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!

  • @anil_7737
    @anil_7737 Рік тому

    What is your name bro?

  • @kishorrathva4097
    @kishorrathva4097 2 роки тому

    Thank you