Nodemon不会在Windows Docker环境中重新启动 [英] Nodemon Doesn't Restart in Windows Docker Environment
问题描述
我的目标是建立一个Docker容器,当从主机检测到文件更改时自动重启NodeJS服务器。
My goal is to set up a Docker container that automatically restarts a NodeJS server when file changes are detected from the host machine.
我选择了nodemon来观看文件进行更改。
I have chosen nodemon to watch the files for changes.
在Linux和Mac环境中,nodemon和docker可以正常工作。
On Linux and Mac environments, nodemon and docker are working flawlessly.
但是,何时我在 Windows环境中,nodemon不会重新启动服务器。
However, when I am in a Windows environment, nodemon doesn't restart the server.
文件在主机上更新,并使用我的docker-compose.yml文件中的 volumes
参数。
The files are updated on the host machine, and are linked using the volumes
parameter in my docker-compose.yml file.
运行 docker exec< container-name>时,我看到文件已更改。猫/path/to/fileChanged.js
。通过这种方式,我知道文件已正确链接并且已在容器中进行了修改。
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.
nodemon是否有任何原因无法为Windows重新启动服务器? ?
推荐答案
使用 nodemon --legacy-watch
轮询文件更改,而不是侦听文件系统事件。
Use nodemon --legacy-watch
to poll for file changes instead of listening to file system events.
VirtualBox doesn不会通过vboxfs共享将文件系统事件传递给Linux VM。如果您使用的是适用于Windows的Docker,则似乎HyperV也不会传播文件系统事件。
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.
这篇关于Nodemon不会在Windows Docker环境中重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!