Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodemon not restarting in docker #1447

Comments

@leifdejong
Copy link

leifdejong commented Nov 12, 2018

  • nodemon -v: 1.18.6 (latest)
  • node -v: 10.13
  • Operating system/terminal environment:
    • Docker version 18.06.1-ce, build e68fc7a
    • docker-compose version 1.22.0, build f46880f
  • Command you ran:

docker-compose.yml:

version: '3.1'

services:
  node:
    image: node:10
    working_dir: /usr/local/src/
    volumes:
      - .:/usr/local/src/
    environment:
      - NODE_ENV=development
    command: bash -c "nodemon --watch src --exec 'node src/server.js'"

Run: docker-compose up

Expected behaviour

Should restart when I change a file in src/

Actual behaviour

Does not restart

Steps to reproduce

  1. mkdir -p test/src && touch test/docker-compose.yml && touch test/src/server.js
  2. Copy above contents into docker-compose.yml
  3. Run cd test && docker-compose up
  4. Try changing something in server.js and observe

Known Solution

If I add the -L flag, everything works great! Something got killed in the latest version (docker/labs#378)

@remy
Copy link
Owner

remy commented Nov 13, 2018

Is this a nodemon issue or docker?

@leifdejong
Copy link
Author

@remy this appears to be a symptom of a nodemon change. After upgrading, we had to follow https://github.com/remy/nodemon#application-isnt-restarting to make it work in docker.

@stale
Copy link

stale bot commented Nov 27, 2018

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

@stale stale bot added the stale no activity for 2 weeks label Nov 27, 2018
@leifdejong
Copy link
Author

@remy any thoughts on this?

@stale stale bot removed the stale no activity for 2 weeks label Nov 27, 2018
@remy
Copy link
Owner

remy commented Dec 6, 2018

Missed your comment. Are you able to replicate intended behaviour with a previous version of nodemon (with the latest docker)? I've not got any experience with docker, so I don't fully understand the internals of what happens with docker.

@myfancypants
Copy link

myfancypants commented Dec 8, 2018

I've managed to spend more than a day debugging this problem so let me help provide my learnings.

For some context, I have an extra step in my build process. I have tsc --watch handling code transpiling and bundling. Previously with an earlier version of nodemon I had this system running locally.

Through quite a bit of investigation I started to notice that while nodemon was not restarting, the updated build files were successfully being picked up within the container itself.

A further insight revealed that if I manually changed a file from within the container, nodemon restarted as expected.

With this I then attempted to just run my watch system from the container itself and voila, I had nodemon restarted following local changes again!

To be perfectly honest I don't know exactly why changing the execution context of the file changes matters.

I attempted to revert the commits of the last few versions of nodemon to see if that fixed the original problem and still saw no change in behavior.

My hunch is that a dependency of nodemon that handles the fs watch has broken the existing functionality. Somehow in the execution path of mac os file change -> container volume symlink change is not being picked up by nodemon.

Considering I don't know enough about nodemon's internals and I have a working environment again, i've not looked further into trying to figure out what dependency might be to blame here.

@remy
Copy link
Owner

remy commented Dec 10, 2018

Key question (that I'll be adding to my issue template): what docker image are you using?

I think this is a dupe of #1484 and I think you're using Alpine, so it'll be fixed once I push a fix…

@remy remy closed this as completed in 735afd5 Dec 10, 2018
@remy
Copy link
Owner

remy commented Dec 10, 2018

Live fix in nodemon@1.18.8 (core change in pstree.remy…again).

@tudtude
Copy link

tudtude commented Jan 9, 2019

I was fix this problem @leifdejong it work! just change some in docker-compose.yml

command nodemon index.js
command nodemon -L index.js

@allbto
Copy link

allbto commented Mar 18, 2019

This worked for me (adding inotify-tools to my Dockerfile): https://stackoverflow.com/a/46804953/2397773

It also fixed the same issue I had with webpack-dev-server not reloading.

@rodrigoespinozadev
Copy link

I was fix this problem @leifdejong it work! just change some in docker-compose.yml

command nodemon index.js
command nodemon -L index.js

Thank you very much this worked for me

@nitinprajapati
Copy link

I was fix this problem @leifdejong it work! just change some in docker-compose.yml

command nodemon index.js
command nodemon -L index.js

Thanks working for me.

@nhatminh9305
Copy link

I was fix this problem @leifdejong it work! just change some in docker-compose.yml

command nodemon index.js
command nodemon -L index.js

thanks u.

@NomadXD
Copy link

NomadXD commented Mar 30, 2020

For me even using the -L flag does not work. I am using a node image as the base image and when installing nodemon inside the container it gives the following warning.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/nodemon/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

I think chokidar and fsevents are related to this nodemon restarting. any suggestions how to fix ?

@SushiWaUmai
Copy link

For me even using the -L flag does not work. I am using a node image as the base image and when installing nodemon inside the container it gives the following warning.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/nodemon/node_modules/chokidar/node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

I think chokidar and fsevents are related to this nodemon restarting. any suggestions how to fix ?

Having the same issue, any ideas?

@anildalar
Copy link

command nodemon -L index.js

It worked for me as well THanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment