-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker containers are too slow on WSL 2 #4387
Comments
I've had this issue when my project files were in the Windows filesystem and being accessed from |
@Drakota Gonna give it a try then to see if it's the problem. I prefer to have the files on windows filesystem though cuz I like to hav e my code synced on OneDrive. |
When I used Vagrant in the past the solution for this was enabling NFS feature on Windows. Have u tried this? |
Haven't used Vagrant with WSL or NFS yet unfortunately, let me know if moving your project's file fixed it. |
I haven't tested it yet. It would take some time for me to move all the projects I have to my WSL home folder and I don't have time for that now. I have upgraded to build 18956, but it's still slow. So I went back to Docker for Windows. |
probably related to #4197 |
Almost certainly, since "transferring everything into my home directory" appears to mitigate. If your primary filesystem for Docker "work" (let's say a build) is on NTFS, then Windows Docker is a much better fit until filesystem perf improves. |
Disabling Hyper-v worked for me: To disable Hyper-v run this command from an elevated Windows console (cmd or PowerShell): |
Very slow how to fix? |
Just to let you know: I have the same problem with WSL2 using WordPress containers. A pageview in my simple website takes 8s, while in WSL it takes less than a second. That's why I turned back to WSL1. |
@xermus Are you using Windows Preview builds? If so, you will now be able to access your WSL home directory from Windows Explorer. So just move all your project files to your home directory and the slowness will be gone xD |
thanks @lucasctd - I tried it out, copied my project folder to the Desktop, set Docker to use WSL2 again, started the containers, but speed problem remained unfortunately. Reverting back to WSL1... |
@pdmwu Are you using Docker For Windows with that WSL integration feature? |
@lucasctd I also experience this problem. With Hyper-V I was compiling a project in about 5 minutes, now with WSL2 the operation takes about half an hour. The volume is on the Windows FS tho... |
I stumbled upon https://docs.microsoft.com/en-us/windows/wsl/compare-versions and discovered that WSL2 is actually slower than WSL1 if your project files are on the Windows file system. This was exactly my case as my project files were in C:\Users\etc... So I decided to try 2 different things: a) First I disabled the WSL2 integration in Docker so it would switch back to Hyper-V. Then I did b) I also copied my project files into \wsl$\Ubuntu\home\ while having the Docker WSL2 integration enabled, then brought my images up with So it seems like it's a file system performance issue. Sharing files between the Windows FS and Linux simply doesn't work too well. If you want performance, you have to stick to one of the 2 options outlined above. |
@dherran I think this is the workaround for now, performance is terrible otherwise. I went back to Hyper-V for now, maybe until WSL3 :D |
And here we go again, Docker Desktop... |
The solution at the moment is to return to Hyper-v, right? Because I'm making requests (I tested returns only one string) API that take a certain 6s.... =/ |
@garbinmarcelo Just place your code inside WSL's home directory. The slowness issue happens only when you try to access Windows FS from WSL. |
Do I have to copy all the projects into wsl? Still, it is not a good solution, as I have several projects for example on the D: partition, in which case I would have to stop using this partition to use everything within the wsl path? |
@garbinmarcelo Yep. Otherwise, you could use a NFS server on Windows, pointing it to your D partition and then install a NFS client on WSL to mount the partition there. I used to do it and worked pretty well, the only use issue I had was the lack of free NFS server softwares for Windows, I found two but they both didn't work, the only one that worked was a paid (and expensive [for me]) one xD |
@lucasctd Okay, so it's almost (actually lol) better to use Linux hehehe... I'm seriously thinking about dualboot .. I'll try to go back to Hyper-v to see if there is any difference in speed... Valeuu brow 🍻 |
Hyper-V worked for me. I have my github projects folder in another drive so that was the only option. |
Now I'm not getting back to Hyper-v... An error has occurred .. How can I go back, would you know? This is the beginning of the error log:
|
WSL2 also container based also still slow for me. |
Put your volumes/code etc into the Ubuntu or w/e WSL2 distro you are using. Create a network mapped drive for \wsl$\Ubuntu for example. (Replace with name of distro e.g. Ubuntu-20.04 Doing large operations with a git client or other tools from Windows can be slow though. Run your docker-compose.yml or w/e up from the Ubuntu (Linux distro) WSL 2 and it goes much faster. |
Using an actual GNU/Linux distribution installation in bare metal would be much faster and a lot easier that WSL itself. And that video would be just in 1 minute. |
@Biswa96 For people who need windows for work it's a decent solution |
@enghelewa What is unique feature of windows if you already need Linux? Anyway, I think your opinion is correct. |
Why is this closed? I mean @enghelewa solution is ok, but in terms of WSL2/WSL is quite crappy to need to find these workarounds |
@SlyDeath for me I need it because of MS Office, Adobe CC, and to work on old crappy .net projects. |
@enghelewa My condolences 😅 |
How do you execute your docker command then from your WSL or from your windows ? |
@GF-Huang That's pretty weird, it runs really well here. |
Just want to bump this as it's Dec 8th with no resolution in sight. HTTP Requests against a Rails stack that executes in <1s on my macbook take 30+ seconds in WSL2 w/Windows. |
tl;dr effect of virtualization. |
Yes, well, a boy can dream :)
Thanks,
Dallas
---------------------------------------
*Professional leader of highly performant engineering teams since 1997*
*512.923.4426 | Github <https://github.com/codeninja>| Twitter
<https://twitter.com/dallaspool>| Linkedin
<https://linkedin.com/in/dallaspool>*
|
Still nothing? |
same slowness as 2 years ago |
At the risk of sounding like an absolute ungrateful twat, WSL 2 is a massive regression speed wise for docker containers when we were promised 20x the I/O performance. Where did it all go wrong? |
No worries. Windows 11 is here and it's sure to solve all our problems. /s
Thanks,
Dallas
---------------------------------------
*Professional leader of highly performant engineering teams since 1997*
*512.923.4426 | Github <https://github.com/codeninja>| Twitter
<https://twitter.com/dallaspool>| Linkedin
<https://linkedin.com/in/dallaspool>*
|
@codeninja how? |
Can confirm, still a problem in Windows 11 |
any solutions guys? wordpress site on docker so slow on windows 11 |
Best way I found to speed up performance is by using Hyper-V instead sadly. |
@klodianpepkolaj have you tried docker for Windows with WSL2 integration? It should solve all your problems. |
Isn't that the exact problem this thread is detailing? That WSL2 runs terribly on windows when using Docker for Windows. I still haven't seen any notable improvement. |
@noknokcody I don't think so. As some guys have already stated here, it will only be slow if you try to access the files under Also, I suggested Docker for Windows cuz with that one you don't need to install docker and its dependencies manually on WSL and don't need to start it manually every time you restart WSL. |
I currently run a few PHP dev environments through docker where I keep the source code on the host and mount a volume to the container to run my dev server. Currently, my workflow requires this source code to remain on the host. Are you suggesting that there is a way of avoiding slowdowns while adhering to this requirement? |
@noknokcody the only way I found to avoid slowness without having to put the files inside WSL's filesystem was by using a NFS Server on Windows and then mounting the folders on WSL. At the time, I used the following tool: https://www.hanewin.net/nfs-e.htm |
Interesting solution, I might look into that a little more cheers! I still think this issue stands though, accessing files over /mnt/c is slow as heck, and volume mounting is a pretty significant docker feature to neglect. Microsoft is making big claims about the performance of WSL2 but still lag behind HyperV in this use case by at least 500%. |
I was thinking about it because when i was using Docker with Hyper-v in about 3 years it wasn't that slow ( i had Windows running on HDD). I limited WSL2 Ram usage and CPU because it was abusive and it's still slower than it was with Hyper-v |
@noknokcody Hi! |
Your Windows build number:
Microsoft Windows [versão 10.0.18932.1000]
What you're doing and what's happening:
When making requests to nginx container on docker on wsl2, the server takes a lot of time to answer. A simple request that returns a plain ##text takes up to 4 seconds.
After running
sudo docker stats
I got the following results:flowmeapp_web_flowme_1 is the container that's running nginx, as you can see it's only consuming 3.4mb of memory and there are 14.6GB available.
I used to use the same containers on Docker for Windows and they worked fine so I don't think it's something with my docker-compose.yml file.
What's wrong / what should be happening instead:
The request flow should be really faster than it is now.
The text was updated successfully, but these errors were encountered: