1

I use Docker Desktop on Windows 10 (WSL) and need to use Angular on a Docker Volume (with the -v option). Everything works correctly, but the "ng" command seems very slow when it's run from the volume.

I first noticed this running ng serve: the command hangs for more than 1 minute with no log (even in verbose mode) before beginning the compilation. But even ng --version hangs for 15 seconds when it's run from any directory in the volume (the version is 8.1.2) - without any error message (and no docker log). If I run ng --version from any other folder in the container (not in the volume), the version is displayed immediately.

Would you know the reason of this delay or any way to understand and solve it?

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Corentin
  • 189
  • 1
  • 2
  • 13
  • [docker on wsl2 very slow](https://stackoverflow.com/questions/62154016/docker-on-wsl2-very-slow) suggests that it could matter where on disk your application is and the WSL `/home` directory will be much faster. You also might consider `COPY`ing your application code into an image and not bind-mounting it at all. – David Maze Feb 02 '21 at 12:13
  • I tried to change the location of the volume (from the container) accordingly but it remains the same... About COPY, that's what we do in production and it does work well, but we try here to use VOLUME for development purpose. – Corentin Feb 02 '21 at 12:29

1 Answers1

0

I suspect that the main issue is due to the fact that ng commands are read/write intensive. That being said, the Visual Studio Code devcontainer doc indicates:

While using this approach to bind mount the local filesystem into a container is convenient, it does have some performance overhead on Windows and macOS. There are some techniques that you can apply to improve disk performance, or you can open a repository in a container using a isolated container volume instead.

Therefore, instead of mounting the current directory, it would be better in that case to clone the repository in an isolated container volume.

To do so, in VS Code, open the command palette by pressing F1 and select Remote-Containers: Clone Repository in Container Volume. This will create a unique volume for your container with your repository inside.

The techniques mentioned in the quote can be found here.