How to Dockerize NestJS App in Development mode

Опубликовано: 28 Сентябрь 2026
на канале: Aya Othman
1,590
29

In this video, we will dive deep into how to properly Dockerize a NestJS application alongside a MongoDB database specifically for Development Mode. We will build a solid development environment that ensures data persistence and enables seamless Hot Reloading—showing you exactly how to mirror your local code changes instantly inside the container using two different methods: Docker Compose Watch and Bind Mounts!

🚀 What you will learn in this video:
✅ What problem Docker actually solves in local development.
✅ How to write a development Dockerfile while optimizing layer caching and utilizing .dockerignore.
✅ Understanding docker-compose and managing multi-container setups (App + Database).
✅ Understanding port mapping.
✅ What Docker Volumes are and how to persist database data across container restarts.
✅ How to achieve Hot Reloading using the modern Docker Compose Watch feature.
✅ Alternative Hot Reloading workflow: Syncing your local code using traditional Bind Mounts.
✅ Bonus: How to access the MongoDB container via mongosh and connect to it externally using MongoDB Compass.

📂 Source Code & Resources:
GitHub Repository: [https://github.com/Ayanabilothman/doc...]
Docker Documentation: [https://docs.docker.com]
Docker Hub: [https://hub.docker.com/]

⏱️ Timestamps:
00:00 - Introduction: What Problem Does Docker Solve?
03:18 - Image VS Container
06:35 - Walkthrough the demo app
07:29 - Writing the NestJS Dockerfile (Layer Caching & .dockerignore Explained)
20:15 - Writing the docker compose file
22:03 - Understanding Port Mapping
27:44 - Understanding Volumes for Data Persistence
33:39 - Run App & DB containers and test the application
35:25 - Update MONGO_URI
40:10 - Enabling Hot Reloading via Docker Compose Watch
46:35 - Alternative Approach: Hot Reloading via Bind Mounts
51:21 - Ignore dist folder
52:35 - Quick Recap
54:30 - Additional Point 1: Exec into MongoDB Container using mongosh & Connecting to Docker DB via MongoDB Compass
58:23 - Additional Point 2: Testing Data Persistence