Dev.to
5/9/2026

docker-compose for Next.js + NestJS local dev
Short summary
This tutorial provides a production-tested docker-compose.dev.yml configuration for local Next.js + NestJS development, solving common failures: hot reload on macOS via WATCHPACK_POLLING, database readiness timing with healthchecks, and node_modules shadowing with anonymous volumes. Each setting is explained with the specific problem it solves, including Dockerfile.dev examples and networking patterns for client vs. server code.
- •Bind mounts enable hot reload; anonymous volumes prevent node_modules from being overwritten by the mount
- •WATCHPACK_POLLING required on macOS; database healthcheck ensures NestJS doesn't crash on startup
- •NEXT_PUBLIC_API_URL uses localhost for browser code, but server code uses api:4000 for Docker internal networking
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



