您好,登錄后才能下訂單哦!
本篇文章為大家展示了如何分析docker中 WSL 配置與修改問(wèn)題,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
存儲(chǔ)在%UserProfile%目錄中。
用于在作為WSL2版本運(yùn)行的所有已安裝Linux發(fā)行版中全局配置設(shè)置??捎糜赪SL2運(yùn)行的發(fā)行版。
作為WSL 1運(yùn)行的發(fā)行版不會(huì)受到此配置的影響,因?yàn)樗鼈儾皇亲鳛樘摂M機(jī)運(yùn)行的。
要訪問(wèn)您的%UserProfile%目錄,請(qǐng)?jiān)赑owerShell中使用CD~訪問(wèn)您的主目錄(通常是您的用戶(hù)配置文件,C:\Users\<UserName>),或者您可以打開(kāi)Windows文件資源管理器并在地址欄中輸入%UserProfile%。目錄路徑應(yīng)該類(lèi)似于:C:\Users\<UserName>\。wslconfig。WSL將檢測(cè)這些文件的存在,讀取內(nèi)容,并在每次啟動(dòng)WSL時(shí)自動(dòng)應(yīng)用配置設(shè)置。如果文件丟失或格式不正確(標(biāo)記格式不正確),WSL將繼續(xù)正常啟動(dòng),而不應(yīng)用配置設(shè)置。
檢查您正在運(yùn)行的WSL版本。
使用wsl調(diào)整每個(gè)分發(fā)設(shè)置。conf文件僅在Windows Build 17093及更高版本中可用。
wslconfig的配置設(shè)置
這個(gè)wslconfig文件全局配置運(yùn)行WSL2的所有Linux發(fā)行版的設(shè)置。(對(duì)于每個(gè)分發(fā)配置,請(qǐng)參見(jiàn)wsl.conf)。
看見(jiàn)WSLConfigf以獲取有關(guān)存儲(chǔ)位置的信息。wslconfig文件。
筆記
具有的全局配置選項(xiàng)。wslconfigis僅適用于在Windows Build 19041及更高版本中作為WSL 2運(yùn)行的發(fā)行版。請(qǐng)記住,您可能需要運(yùn)行WSL--shutdown來(lái)關(guān)閉WSL2VM,然后重新啟動(dòng)WSL實(shí)例,以使這些更改生效。
此文件可以包含影響為任何WSL 2發(fā)行版供電的VM的以下選項(xiàng):
節(jié)標(biāo)簽:[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的條目必須是帶有轉(zhuǎn)義反斜杠的Windows路徑,例如:C:\\Temp\\myCustomKernel
帶有SizeValue的條目必須是后跟單位的大小,例如8GB或512MB。
值類(lèi)型后面帶有*的條目?jī)H在Windows 11上可用。
實(shí)例wslconfig文件
這個(gè)下面的wslconfigsample文件演示了一些可用的配置選項(xiàng)。在本例中,文件路徑為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
上述內(nèi)容就是如何分析docker中 WSL 配置與修改問(wèn)題,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。