简体   繁体   English

为什么 Docker for Windows 在 WSL2 上运行缓慢?

[英]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.

相关问题 Docker 2.3.0.4 with Devilbox on Windows 10 WSL2 非常慢 - Docker 2.3.0.4 with Devilbox on Windows 10 WSL2 is extremely slow Symfony 在带有 WSL2 的 Docker 中仍然很慢 - Symfony still slow in Docker with WSL2 WSL2 docker-compose - 无法准备上下文 - WSL2 docker-compose - unable to prepare context 从 Docker 容器内部如何连接到 WSL2 分发 - From inside of a Docker container how to connect to a WSL2 distribution 使用 Docker 和 WSL2 在 VSCode 中调试 PHP 时出现问题 - Issues when Debugging PHP in VSCode using Docker and WSL2 WSL2 Ubuntu 20.04、Docker 和 Laravel 启动本地主机不会显示在浏览器上 - WSL2 Ubuntu 20.04, Docker and Laravel launching local host won't display on browser Xdebug 尝试连接到错误的地址(Xdebug、PHP、Docker、VSCode、WSL2) - Xdebug tries to connect to the wrong address (Xdebug, PHP, Docker, VSCode, WSL2) 为什么我的 php docker 容器在 Windows 11 上这么慢? - Why is my php docker container so slow on Windows 11? 为什么 laravel 中的作曲家没有在 wsl 2 docker 中安装 package - Why composer in laravel no install package in wsl 2 docker 当 WSL2 docker 环境中的 Laravel 指向变量文件夹而不是原始项目文件夹时,如何处理工作文件夹? - How to handle working folder when Laravel in WSL2 docker environment point to variable folder instead of original project folder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM