如何分析docker中 WSL 配置与修改问题

本篇文章为大家展示了如何分析docker中 WSL 配置与修改问题,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

如何分析docker中 WSL 配置与修改问题

存储在%UserProfile%目录中。

用于在作为WSL2版本运行的所有已安装Linux发行版中全局配置设置。可用于WSL2运行的发行版。

作为WSL 1运行的发行版不会受到此配置的影响,因为它们不是作为虚拟机运行的。

要访问您的%UserProfile%目录,请在PowerShell中使用CD~访问您的主目录(通常是您的用户配置文件,C:\Users\<UserName>),或者您可以打开Windows文件资源管理器并在地址栏中输入%UserProfile%。目录路径应该类似于:C:\Users\<UserName>\。wslconfig。WSL将检测这些文件的存在,读取内容,并在每次启动WSL时自动应用配置设置。如果文件丢失或格式不正确(标记格式不正确),WSL将继续正常启动,而不应用配置设置。

检查您正在运行的WSL版本。

使用wsl调整每个分发设置。conf文件仅在Windows Build 17093及更高版本中可用。

如何分析docker中 WSL 配置与修改问题

wslconfig的配置设置

这个wslconfig文件全局配置运行WSL2的所有Linux发行版的设置。(对于每个分发配置,请参见wsl.conf)。

看见WSLConfigf以获取有关存储位置的信息。wslconfig文件。

笔记

具有的全局配置选项。wslconfigis仅适用于在Windows Build 19041及更高版本中作为WSL 2运行的发行版。请记住,您可能需要运行WSL--shutdown来关闭WSL2VM,然后重新启动WSL实例,以使这些更改生效。

此文件可以包含影响为任何WSL 2发行版供电的VM的以下选项:

节标签:[wsl2]

keyvaluedefaultnoteskernelstringThe Microsoft built kernel provided inboxAn absolute Windows path to a custom Linux kernel.memorysize50% of total memory># Settings apply across all Linux distros running on WSL 2 [wsl2]   # Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB memory=4GB   # Sets the VM to use two virtual processors processors=2   # Specify a custom Linux kernel to use with your installed distros. The default kernel used can be found at https://github.com/microsoft/WSL2-Linux-Kernel kernel=C:\\temp\\myCustomKernel   # Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6 kernelCommandLine = vsyscall=emulate   # Sets amount of swap storage space to 8GB, default is 25% of available RAM swap=8GB   # Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx swapfile=C:\\temp\\wsl-swap.vhdx   # Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free pageReporting=false   # Turn off default connection to bind WSL 2 localhost to Windows localhost localhostforwarding=true   # Disables nested virtualization nestedVirtualization=false   # Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging debugConsole=true

上述内容就是如何分析docker中 WSL 配置与修改问题,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。

如何分析docker中 WSL 配置与修改问题