Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

webpack-dev-server polling inside docker container - heavy CPU usage

I am running webpack-dev-server inside of a Docker container. For development purposes, I have a local directory bound to the Docker container. It's my understanding that webpack's standard "watch" abilities don't work inside Docker, or at least with volumes bound to the host machine.

But if I turn on polling (watchOptions.poll: true), the Docker container uses a lot of CPU. I can turn down polling to 1000ms or even 5000ms, but that still uses non-negligable amounts of CPU, enough so that my laptop's fans start spinning.

Are there any best practices around limiting CPU usage by a polling webpack-dev-server? Is there anything I can install inside my Linux-based Docker container? I've tried installing the latest inotify-tools, but that doesn't seem to have done the trick.

like image 893
jdelman Avatar asked Jan 04 '18 22:01

jdelman


2 Answers

for windows 10 2004 and docker desktop wsl2 backend, webpack-dev-server watch work inside docker container volumes bound to the wsl2 directory but does not work volumes bound to the windows directory.

I use vscode with remote-containers extension.

I open \\wsl$\Ubuntu-18.04\home\... by vscode and "reopen in container" by command-pallet.

like image 168
Tetsuo Kitamura Avatar answered Oct 18 '22 16:10

Tetsuo Kitamura


The solution I used was the docker-sync utility.

It runs in a container and keeps a Docker volume sync'd using rsync. The updates hit Docker's filesystem listener so you can "watch" instead of "polling".

like image 32
jdelman Avatar answered Oct 18 '22 17:10

jdelman