解决安装 Docker for Windows, Vmmem 内存占用过高问题 作者: Chuwen 时间: 2021-10-30 分类: Windows,Docker  ## 步骤 1. 按下Windows + R 键,输入 `%UserProfile%` 并运行进入用户文件夹 2. 新建文件 `.wslconfig` ,然后记事本编辑 3. 填入以下内容并保存, `memory` 为系统内存上限,这里我限制最大 2GB,可根据自身电脑配置设置 ```conf [wsl2] memory=2GB swap=0 localhostForwarding=true ``` 4. 然后启动 cmd 命令提示符,输入 `wsl --shutdown` 来关闭当前的子系统 5. 然后不出意外 Docker 会发送一个停止的通知,你点击重启的按钮就会重启了 6. 现在内存占用正常多了,这个内存占用正是我们设置的最大占用内存  看了下本地用 Docker 搭建的宝塔面板,内存也显示 2GB:  Ubuntu for WSL(使用 `htop` 命令查看):  ## 相关引用参考 - https://www.cnblogs.com/coding8832/p/14445835.html - https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig > You are using the WSL 2 backend, so resource limits are managed by Windows. > > You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a [.wslconfig file.](https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig ".wslconfig file.")  标签: Docker, Vmmem