Nodemon does not restart in Windows Docker

My goal is to configure the Docker container, which automatically restarts the NodeJS server when file changes are detected from the host machine.

I chose nodemon to view files for changes.

On Linux and Mac environments, nodemon and docker work flawlessly.

However, when I am in a Windows environment , nodemon does not restart the server.

Files are updated on the host machine and are associated with the volumes parameter in the docker-compose.yml file.

I see that the files were changed when starting docker exec <container-name> cat /path/to/fileChanged.js . This way, I know that the files are linked correctly and have been changed in the container.

Is there a reason nodemon does not restart the server for Windows?

+15
source share
2 answers

Use nodemon --legacy-watch to poll file changes instead of listening to file system events.

VirtualBox does not send file system events via vboxfs share to your Linux virtual machine. If you use Docker for Windows, it means that HyperV will not propagate file system events.

+26
source

It is simple, according to the document you have to change:

 nodemon server.js 

so that:

 nodemon --legacy-watch server.js 
0
source

All Articles