title: Yarn is slow and freezes when run via docker exec
body: <p>I recently started using docker (desktop version for Windows) for my node project development. I have a docker-compose file with volume configuration to share the project source files between my host machine and docker container.</p>
  <p>When I need to install a new mode module, I can't do that on my host machine, of course, because it's Windows and docker is Linux or something, so I run <code>docker exec -it my-service bash</code> to &quot;get into&quot; the docker container and then run <code>yarn add something</code> from inside it. The problem is - <code>yarn</code> runs extremely slow and freezes almost all of the time. The docker container then becomes unresponsive, I cannot cancel the <code>yarn</code> command or stop the container using <code>docker-compose stop</code>. The only way I've found to recover is to restart the whole docker engine. So then, to finally install the new module, after docker engine restarts, I delete the node_modules folder and do the same steps again. This time it's still extremely slow, but it doesn't freeze somehow and actually installs the new module. But after some time, when I need to do that again, it freezes again and I have to delete node_modules again...</p>
  <p>I would like to find the reasons why the <code>yarn</code> command is so slow and why it freezes.</p>
  <p>I'm new to docker, so maybe my workflow is not correct.</p>
  <p>I tried increasing RAM limit for docker engine from 2 GB to 8 GB and CPUs limit from 1 to 8, but it had absolutely no effect on the <code>yarn</code> command behavior.</p>
  <p>My project was using file watching with <code>chokidar</code>, so I thought maybe that could cause the problem, but disabling it had no effect either.</p>
  <p>I also thought the problem could be the file sharing mechanism between host machine (Windows) and docker container, but if it is the case, I do not know how to fix it. I suppose I then should somehow separate node_modules from the source directory and make them private to docker container, so that they are not shared with host machine.</p>
  <p>This is quite a severe problem, as it slows the development down a lot. Please share any of your ideas about what could be wrong. I would even consider changing my development environment to Linux if the problem was caused by the file sharing mechanism between Windows and docker container.</p>