nodemon
nodemon copied to clipboard
Nodemon not restarting when files change in Docker
-
nodemon -v
: 2.0.6 -
node -v
: v12.18.1 - Operating system/terminal environment: MacOS
- Using Docker? What image: Yes,
node:12
. RunningDocker version 19.03.13, build 4484c46d9d
. - Command you ran:
nodemon --watch server server/app.js
Expected behaviour
The app is running inside a Docker container, with the project folder mounted as a volume. When a file is changed from the host machine, nodemon should restart the app.
Actual behaviour
Nodemon doesn't seem to notice the file change and doesn't restart the app. cat
ing the file or checking the timestamp inside the Docker container, the file is changed in the container as well.
NOTE: Using the -L
flag does work. Nodemon will respond to changes with -L
.
Steps to reproduce
I created a repo that reproduces the issue: https://github.com/cullylarson/nodemon-watch-issue
The docker-compose file mounts the volume as read-only. I've tried it mounting as writable, but get the same result.
Have you tried passing the -L flag to nodemon? Do nodemon --help options
for more info.
doesnt work for me either
@acannon828 -L
works. I actually mention it in the repo. I'll update the issue to include it as well. That's what I've been using since noticing this problem. Though it doesn't seem like a great long-term solution, especially if this is broadly affecting nodemon in Docker (+ MacOS?).
I think chokidar has made some recent updates to fix Docker issues. Maybe this is just a matter of updating the chokidar dep?
so could you help me with this , I'm new to express and what is occurring that the latest version isn't restarting or refreshing the browser.
@tristoncarter34 This may not be the same issue. Have you tried posting your question on Stackoverflow?
actually no i thought maybe you guys can give some insight on my issue that only started this few minutes ago
FYI, I tried cloning nodemon and updating chokidar to 3.4.2 and it doesn't seem to have fixed the issue.
I reproduced the same problem with chokidar alone, so this might just be a chokidar issue. I posted an issue there: https://github.com/paulmillr/chokidar/issues/1051.
I have this issue when running nodemon in a fuse mount, I don't know how these file change events look like and what handles them, might this be a similar or the same chokidar issue? Or should I open a separate one about fuse mounts? I think legacyWatch solves it but I don't wanna do that.
@bpstrngr I don't know if it's the same. I have gRPC FUSE turned off.
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3
It is still an issue. It just seems to be an issue with chokidar.
Might be worth creating a completely pared back test that only uses chokidar in docker to test for changes?
@remy I posted an issue in the chokidar repo a while back, with an example of how to reproduce using only chokidar: https://github.com/paulmillr/chokidar/issues/1051.
NOTE: Using the
-L
flag does work. Nodemon will respond to changes with-L
.
Thank you, @cullylarson . Solved it for me too.
😢
I am having this same issue, and the -L
flag makes no impact.
Same here -L
or --legacy-watch
does not work.
Same here
-L
or--legacy-watch
does not work.
Maybe I can help you, please write your version of docker, node, nodemon and OS type
I have:
docker 20.10.10 docker compose 2.1.1 node 16.13.0 nodemon 2.0.15 Windows
Same here
-L
or--legacy-watch
does not work.Maybe I can help you, please write your version of docker, node, nodemon and OS type
I have:
docker 20.10.10
docker compose 2.1.1
node 16.13.0
nodemon 2.0.15
Windows
I have the same problem on windows, on my mac, it runs fine.
docker 20.10.10 docker compose 2.1.1 node 16.13.0 nodemon 2.0.15 Windows
I mount the repo into the docker container, it spins up and works with requests but never triggers a restart when files in scope are changed. The Dockerfile and the exact same setup works on Mac and Ubuntu desktops
I solved my problem by putting the src directory into a volume.
--legacy-watch
works for me. However it doesn't respect the directory names to restrict the watch to. This is a lot of overhead in projects where we split server and worker code and need to manage the lifecycle separately.
Should watching the specific directories be working using --legacy-watch
?
Here's my docker file:
version: '3.4'
x-service-defaults:
&service-defaults
image: dav/gdal:latest
build:
context: .
dockerfile: ./Dockerfile
environment:
NODE_ENV: production
REDIS_HOST: redis
volumes:
- ./src:/dav/src
- ./data:/data
services:
worker:
<<: *service-defaults
command:
[
"nodemon",
"--legacy-watch",
"jobs/workers",
"src/jobs/workers/index.js"
]
web:
<<: *service-defaults
ports:
- 5000:5000
- 9229:9229
command:
[
"nodemon",
"--inspect=0.0.0.0:9229",
"--legacy-watch",
"/dav/src/app.js",
"-e",
"html,css,js,sql"
]
redis:
image: redis:6.0.16-alpine
ports:
- 6379:6379
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3
Automatically closing this issue due to lack of activity
nodemon -L did the trick here as well. Thanks.
nodemon -L
worked for me as well
woaw thank you so much, nodemon --legacy-watch
work on me