Docker volumes on WSL2 using Docker Desktop
As @Pablo mentioned, the Best-Practice seems to be using WSL File system for mapping Volumes.
Take a look at the Docker Documentation concerning WSL2:
Best practices
- To 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 (i.e., with
docker run -v <host-path>:<container-path>
) in the Linux filesystem, rather than the Windows filesystem. - Linux containers only receive file change events (“inotify events”) if the original files are stored in the Linux filesystem.
- Performance is much higher when files are bind-mounted from the Linux filesystem, rather than remoted from the Windows host. 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
.
- Store source code and other data that is bind-mounted into Linux containers (i.e., with
- If you have concerns about the size of the docker-desktop-data VHDX, or need to change it, take a look at the WSL tooling built into Windows.
- If you have concerns about CPU or memory usage, you can configure limits on the memory, CPU, Swap size allocated to the WSL 2 utility VM.
- To avoid any potential conflicts with using WSL 2 on Docker Desktop, you must uninstall any previous versions of Docker Engine and CLI installed directly through Linux distributions before installing Docker Desktop.
Everything works perfectly now, it seems that my problem was that my WSL distro was still in version 1. You can verify it with the command : wsl -l -v
NAME STATE VERSION
* docker-desktop-data Stopped 2
docker-desktop Stopped 2
Ubuntu-20.04 Running 2 <- This was at 1
Upgrade to WSL2