Within Docker VM, Gulp-Watch Seems to not work well on volumes hosted from the host OS

boot2docker, docker, gulp, gulp-watch, node.js

Solution

For anyone using gulp4

The only way I could get this to work is to use `usePolling` like below

gulp.watch('./**/*', {interval: 1000, usePolling: true}, gulp.series('superTask'));

Problem

So I have a setup, probably as most people have, where their app code is mounted into a Docker container through a separate volume. The problem is that if I run gulp, and specifically gulp-watch, to watch for file modifications etc. within docker, on the app code mounted within the docker container, to properly build and restart node within the docker container as necessary, it seems to get cpu intensive (as in polling for file changes instead of listening for file change events) to the point where my machine buckles. I think this is due to a limitation of having the file system mounted from the native host to the docker container but how are folks working around this? Are they doing all of their work in the container? Native host then constantly building? Or am I missing something where my setup is incorrect with gulp-watch / nodemon?

Original source