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

Closed
leifdejong opened this issue Nov 12, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@leifdejong
Copy link

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

This comment has been minimized.

Copy link
Owner

commented Nov 13, 2018

Is this a nodemon issue or docker?

@leifdejong

This comment has been minimized.

Copy link
Author

commented Nov 13, 2018

@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

This comment has been minimized.

Copy link

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 label Nov 27, 2018

@leifdejong

This comment has been minimized.

Copy link
Author

commented Nov 27, 2018

@remy any thoughts on this?

@stale stale bot removed the stale label Nov 27, 2018

@remy

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

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 in 735afd5 Dec 10, 2018

@remy

This comment has been minimized.

Copy link
Owner

commented Dec 10, 2018

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

@tudtude

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.