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
Boom! Just what I was looking for. Clear and concise. Thanks man 😃
@DevOpsDirective
2 жыл бұрын
Thanks, @Simon -- I'm glad it helped! 🎉
I love how you break everything down to understandable elements in your videos!
@DevOpsDirective
2 жыл бұрын
Thank you for the kind words! 🎉
@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
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
2 жыл бұрын
Awesome -- glad to have helped! 🎉
@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
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).
Great video! Thank you for making this, super clear!
Brilliant docker tips, nice and to the point! Thank you 👍
Solid tutorial, very clear. Didn’t know how to use the debugger like this.
@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.
Thank you for the explanation, this is what I'm looking for!
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
Жыл бұрын
Awesome -- currently working on a multi-hour docker deep dive course due out next month! Stay tuned!
@harbingerization
Жыл бұрын
@@DevOpsDirective oh sweet! Ya I’ll hang out for that!
@alleandromurrieta2366
Жыл бұрын
is it work on Windows 11?
I'm new with Docker, but this tutorial was excelent. Thank you so much
Great stuff! Pretty much exactly what I was looking for and even more.
@DevOpsDirective
Жыл бұрын
Awesome!
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?
Just saw your video on the Traversy Media channel. It was very good!
thats just gold, dude! congrats
@DevOpsDirective
2 жыл бұрын
🏅🙏🎉
Man!! That's beautiful!
Its like you understood my problem! Thanks!
Playing with docker. Was frustrated with parameters in "docker run", so thanks for showing docker compose ;)
@DevOpsDirective
2 жыл бұрын
Yeah it is nice to have all of the configuration encoded in the one file!
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
Жыл бұрын
Awesome! Welcome to the Team, Shea! 🤝
Awesome man thanks, exactly what I was searching for. Liked and sub'd!
@DevOpsDirective
2 жыл бұрын
Awesome, thank you!
Thank you for this. You’re awesome!
@DevOpsDirective
2 жыл бұрын
You are welcome, @PkmmteXeleon! 🎉
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... 😅
Nice video !!
@DevOpsDirective
Жыл бұрын
Thank you! Cheers!
Thank you! Subscribed!
@DevOpsDirective
2 жыл бұрын
🎉🎉🎉
Thanks, and for angular?, can I use nodemon? for hot reloading.
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
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.
how to run tests like unit tests, integration tests inside docker containers using jest ?
Could you please help me how to set it up with Kubernetes with Skaffold?
immediately hit subscribe after watching your video!
@DevOpsDirective
Жыл бұрын
🤝
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
Question: adding node_modules to the .dockerignore woulndn't have the same effect than binding it to a "empty" path as you did?
@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!
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
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
Hey Sir, hope you're fine. May I ask you a question? What if I install a dependency, should I always rebuild the container?
hi Bro, I need somehelp, I've spend my day to figure it out, but on my Windows 11 its does not work..
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
Thaaanks!
@DevOpsDirective
2 жыл бұрын
You're weeelcome!
Thanks!
@DevOpsDirective
Жыл бұрын
You’re welcome, Lucas!
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
2 жыл бұрын
Yes, you will have to rebuild when installing new dependencies.
Hi, can we use dockerignore for ignoring node_modules during volume mount?
@DevOpsDirective
Жыл бұрын
Yes! That is a better solution I forgot about while filming this
Beautiful!
@DevOpsDirective
2 жыл бұрын
Thank you! Where from Tennessee? I'm from NC
@mikopiko
2 жыл бұрын
@@DevOpsDirective Nashville!
@DevOpsDirective
2 жыл бұрын
@@mikopiko Nice!
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
8 ай бұрын
Do something more complex like what
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
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
How come that you didn't need to use --legacy-watch flag for nodemon?
Sir i am working in fastapi which module i am install in docker file instead nodemon
@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
thanks man
@DevOpsDirective
2 жыл бұрын
You are welcome!
Thankyou 🙏🏽
@DevOpsDirective
2 жыл бұрын
You are welcome, @pramod!
Thank you
@DevOpsDirective
2 жыл бұрын
You are welcome @Kishor! 🙏
It creates a persistance node_module volume so it gets dirty :|
Any ideas why nodemon still doesnt reload? I rewatched the video like 5 times by now
@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
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
2 жыл бұрын
I'm glad you were able to figure it out! Nice work!
Bless
Hello! Nice tutorial, I am trying to connect this with a MariaDB database (another service in the docker-compose) and I can't.
❤❤❤
What if we decide to add a new dependency ?
@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
2 жыл бұрын
@@DevOpsDirective Thanks, appreciate the fast response!
Nice vidéo.. I came from traversty media.. Brad's channel
@DevOpsDirective
2 жыл бұрын
Awesome, welcome to the team! 😀
@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
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
2 жыл бұрын
@@DevOpsDirective thanks for the advice.. I should probably start from development..
What is your name bro?
@DevOpsDirective
Жыл бұрын
?… I say it 30 seconds into the video 😅
Thank you
@DevOpsDirective
2 жыл бұрын
You're welcome @Gianni!