本篇文章为大家展示了如何分析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及更高版本中可用。
wslconfig的配置设置
这个wslconfig文件全局配置运行WSL2的所有Linux发行版的设置。(对于每个分发配置,请参见wsl.conf)。
看见WSLConfigf以获取有关存储位置的信息。wslconfig文件。
笔记
具有的全局配置选项。wslconfigis仅适用于在Windows Build 19041及更高版本中作为WSL 2运行的发行版。请记住,您可能需要运行WSL--shutdown来关闭WSL2VM,然后重新启动WSL实例,以使这些更改生效。
此文件可以包含影响为任何WSL 2发行版供电的VM的以下选项:
节标签:[wsl2]
key | value | default | notes |
---|---|---|---|
kernel | string | The Microsoft built kernel provided inbox | An absolute Windows path to a custom Linux kernel. |
memory | size | 50% of total memory on Windows or 8GB, whichever is less; on builds before 20175: 80% of your total memory on Windows | How much memory to assign to the WSL 2 VM. |
processors | number | The same number of processors on Windows | How many processors to assign to the WSL 2 VM. |
localhostForwarding | boolean | true | Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via localhost:port. |
kernelCommandLine | string | Blank | Additional kernel command line arguments. |
swap | size | 25% of memory size on Windows rounded up to the nearest GB | How much swap space to add to the WSL 2 VM, 0 for no swap file. Swap storage is disk-based RAM used when memory demand exceeds limit on hardware device. |
swapFile | string | %USERPROFILE%\AppData\Local\Temp\swap.vhdx | An absolute Windows path to the swap virtual hard disk. |
pageReporting | boolean | true | Default true setting enables Windows to reclaim unused memory allocated to WSL 2 virtual machine. |
guiApplications | boolean* | true | Boolean to turn on or off support for GUI applications (WSLg) in WSL. Only available for Windows 11. |
debugConsole | boolean* | false | Boolean to turn on an output console Window that shows the contents of dmesg upon start of a WSL 2 distro instance. Only available for Windows 11. |
nestedVirtualization | boolean* | true | Boolean to turn on or off nested virtualization, enabling other nested VMs to run inside WSL 2. Only available for Windows 11. |
vmIdleTimeout | number* | 60000 | The number of milliseconds that a VM is idle, before it is shut down. Only available for Windows 11. |
带有pathValue的条目必须是带有转义反斜杠的Windows路径,例如:C:\\Temp\\myCustomKernel
带有SizeValue的条目必须是后跟单位的大小,例如8GB或512MB。
值类型后面带有*的条目仅在Windows 11上可用。
实例wslconfig文件
这个下面的wslconfigsample文件演示了一些可用的配置选项。在本例中,文件路径为isC:\Users\<UserName>\。wslconfig。
# 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 配置与修改问题,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。