Nodemon Doesn't Restart in Windows Docker Environment

旧街凉风 提交于 2019-12-18 11:45:03

问题


My goal is to set up a Docker container that automatically restarts a NodeJS server when file changes are detected from the host machine.

I have chosen nodemon to watch the files for changes.

On Linux and Mac environments, nodemon and docker are working flawlessly.

However, when I am in a Windows environment, nodemon doesn't restart the server.

The files are updated on the host machine, and are linked using the volumes parameter in my docker-compose.yml file.

I can see the files have changed when I run docker exec <container-name> cat /path/to/fileChanged.js. This way I know the files are being linked correctly and have been modified in the container.

Is there any reason why nodemon doesn't restart the server for Windows?


回答1:


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

VirtualBox doesn't pass file system events over the vboxfs share to your Linux VM. If you're using Docker for Windows, it would appear HyperV doesn't propagate file system events either.




回答2:


It is simple, according to the doc you must change:

nodemon server.js

to:

nodemon --legacy-watch server.js



回答3:


This was an issue in the docker for Windows. Now it's fixed

https://www.docker.com/blog/new-filesharing-implementation-in-docker-desktop-windows/



来源:https://stackoverflow.com/questions/39239686/nodemon-doesnt-restart-in-windows-docker-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!