[英]Why is Docker for Windows running slow on WSL2?
I was trying to get a Laravel image up and running on Docker for Windows (Windows 11), and after config, it was taking several seconds to load each page (insanely slow, definitely outside Laravel benchmarks).我试图在 Docker for Windows (Windows 11) 上启动并运行 Laravel 映像,在配置之后,加载每个页面需要几秒钟(非常慢,绝对超出 Laravel 基准测试)。 I am using WSL2 and have native (full resources) allocated to the VM.
我正在使用 WSL2 并将本机(完整资源)分配给 VM。 Why is it running so slow?
为什么运行这么慢?
I inspected resource allocation and it shouldn't be a problem (50% memory and all cores).我检查了资源分配,这应该不是问题(50% 内存和所有内核)。 I have a fairly beefy machine.
我有一台相当强大的机器。 I tried a reinstall and new Docker image and closed all competing tasks.
我尝试重新安装新的 Docker 映像并关闭所有竞争任务。
TL;DR: don't host docker files on the WSL mount. TL;DR:不要在 WSL 挂载上托管 docker 文件。 Either use non-WSL docker or do an SSH deployment to the WSL local filesystem.
使用非 WSL docker 或对 WSL 本地文件系统进行 SSH 部署。
The issue ended up being that my project files were loaded under /mnt/c in WSL, and, for some reason, this is VERY inefficient for file access and modification.问题最终是我的项目文件被加载到 WSL 中的 /mnt/c 下,并且出于某种原因,这对于文件访问和修改来说非常低效。 I ended up moving my files to a local folder in the VM (for me, this was my home folder) and page loads reduced to sub-second.
我最终将我的文件移动到 VM 中的本地文件夹(对我来说,这是我的主文件夹)并且页面加载减少到亚秒级。 Just the move (mv x->y) took a few minutes and my fans were going crazy.
只是移动 (mv x->y) 花了几分钟,我的粉丝们都快疯了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.