How to run nodemon from docker with no load on the CPU?

The files exist:

FROM node:alpine
RUN yarn global add nodemon

version: '3'
 build: ./app/
 - "./app:/app"
 - "9000:3000"
 command: "nodemon --legacy-watch --polling-interval 4000 /app/bin/server.node.js"

A simple container that runs nodemon and watch for changes /app/bin/server.node.js (hello world Express). Everything works, but the problem is that after running nodemon CPU load by process com.docker.hyperkit grows (at least) 150%.

If nodemon to replace the usual node:command: "node /app/bin/server.node.js"then the tracking file is not happening and the CPU load does not occur.

This problem was many, according to reports in github issues, etc. in 2016-2017. The solution was to reduce the polling interval you have nodemon and use the legacy-watch, suggest that even in official documentation. In my case, unfortunately, did not help.

Have noticed that if you ignore the load and change server.node.js then nodemon in docker is restarted more than once, as it should be, and 5-20 times with almost no delay (number of restarts is not always the same). There is a sense that nodemon constantly receives notification that the file has changed checks to see what part has changed, but finds no differences and falls asleep.

Has anyone encountered such a behavior tracking file in docker? Is there any rational solution for this phenomenon?

Thanks in advance.
June 3rd 19 at 19:09
1 answer
June 3rd 19 at 19:11
Some time having suffered with nodemon we took pm2-dev and it just got better

Find more questions by tags Node.jsmacOSDocker