I have Windows 10 Professional 2004 build 19041.329.
I have the latest Docker Desktop for windows, and have chosen Ubuntu 18.04 LTS as my WSL distro.
I have set all the proper settings to enable WSL 2 in Docker Desktop, and am able to run commands like docker info
without issue.
However, when I try to run docker build -t mytestimage:1.0 .
via a Ubuntu terminal, it takes several minutes, and then sends the build context to the docker daemon, but does so VERY slowly.
If I run the same command from a Windows command prompt, it works very quickly
I did not have this problem with WSL 1, and am unsure how to even diagnose what might be wrong and why this is so slow in WSL 2.
Before you install the Docker Desktop WSL 2 backend, you must complete the following steps: Install Windows 10, version 1903 or higher. Enable WSL 2 feature on Windows. For detailed instructions, refer to the Microsoft documentation. Download and install the Linux kernel update package.
Install Docker on Windows Subsystem for Linux v2 (Ubuntu) 1 Setup WSL2. 2 Install Docker. From WSL bash, run the following commands to setup Docker. These are nearly identical to setting up on... 3 Finalizing setup. Currently, Docker doesn't auto start, so you have to start the service each time. The below command... 4 Lagniappe. More ...
Setup WSL2. Setup instructions for WSL2 are available here: Make sure to install the Ubuntu distro from the Microsoft Store. Once setup, start a command prompt and run the following command to verify Ubuntu is set to version 2. # Set WSL to default to v2 wsl --set-default-version 2 # check the version wsl -l -v # Output should show Ubuntu ...
Once installed, start Docker Desktop from the Windows Start menu, then select the Docker icon from the hidden icons menu of your taskbar. Right-click the icon to display the Docker commands menu and select "Settings". Ensure that "Use the WSL 2 based engine" is checked in Settings > General.
I have experienced this problem. It's to do with the way WSL and windows share filesystems. The best solution I have found is to use a bash container when using the Linux filesystem and a powershell prompt when using the windows filesystem. When you use a bash session on the windows filesystem things are very slow. The same problem occurs when trying to access the Linux filesystem with powershell (though that's much harder).
You can get to the Linux filesystem in bash by issuing a cd
command to get to your Linux home folder. I do most of my work in this way and it's very fast. From there just use git to clone your repo on the Linux fs and everything will work rapidly.
Alternatively, use powershell to clone your repo into C:/Users/home/git/myproject
and you'll find that the system is also responsive, but you're no longer using Linux. I am currently working on a project that needs to use windows executables and I'm forced to work this way with that and have found that it is also fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With