您好,登錄后才能下訂單哦!
本篇文章為大家展示了如何分析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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。