Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 297
adrian Avatar asked Feb 23 '15 19:02

adrian


4 Answers

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'));
like image 119
el-davo Avatar answered Nov 14 '22 08:11

el-davo


Try changing the gulp.watch options. This has been much better for me:

gulp.watch('./**/*', {interval: 1000, mode: 'poll'}, ['build']);
like image 6
Jesse Fulton Avatar answered Nov 14 '22 09:11

Jesse Fulton


You should use the plugin gulp-watch instead of gulp.watch. The latter uses stat polling, which is much too heavy for the shared file system. gulp-watch uses inotify events to watch the file system on OSX.

like image 4
mochtu Avatar answered Nov 14 '22 09:11

mochtu


The previous answer of usePoll: true didn't work. This one did:

gulp.watch('./**/*', {interval: 1000, usePolling: true}, ['build']);
like image 1
Robin Bank Avatar answered Nov 14 '22 09:11

Robin Bank