content/manuals/desktop/features/wsl/best-practices.md
This page covers recommendations when running Docker Desktop on Windows using WSL 2, including version requirements and file system performance.
Always use the latest version of WSL.
At a minimum you must use WSL version 2.1.5, otherwise Docker Desktop may not work as expected. Testing, development, and documentation is based on the newest kernel versions. Older versions of WSL can cause:
vmmem.exe to consume all memoryTo get the best out of the file system performance when bind-mounting files, store source code and other data that is bind-mounted into Linux containers. For instance, use docker run -v <host-path>:<container-path> in the Linux file system, rather than the Windows file system. You can also refer to Microsoft's recommendation.
Linux containers only receive file change events, “inotify events”, if the original files are stored in the Linux filesystem. For example, some web development workflows rely on inotify events for automatic reloading when files have changed.
Performance is much higher when files are bind-mounted from the Linux filesystem, rather than accessed from the Windows host filesystem. Therefore avoid docker run -v /mnt/c/users:/users where /mnt/c is mounted from Windows.
Instead, from a Linux shell use a command like docker run -v ~/my-project:/sources <my-image> where ~ is expanded by the Linux shell to $HOME.
If you have concerns about CPU or memory usage, configure limits on the memory, CPU, and swap size allocated to the WSL 2 utility VM.