关于docker中 WSL 配置与修改问题
https://docs.microsoft.com/en-us/windows/wsl/wsl-config
.wslconfig
- stored in your
%userprofile%
directory. - used to configure settings globally across all installed linux distributions running as the wsl 2 version.can be usedonly for distributions run by wsl 2.
- distributions running as wsl 1 will not be affected by this configuration as they are not running as a virtual machine.
- to get to your
%userprofile%
directory, in powershell, usecd ~
to access your home directory (which is typically your user profile,c:\users\<username>
) or you can open windows file explorer and enter%userprofile%
in the address bar. the directory path should look something like:c:\users\<username>\.wslconfig
.wsl will detect the existence of these files, read the contents, and automatically apply the configuration settings every time you launch wsl. if the file is missing or malformed (improper markup formatting), wsl will continue to launch as normal without the configuration settings applied.
check which version of wsl you are running.
note
adjusting per-distribution settings with the wsl.conf file is only available in windows build 17093 and later.
configuration setting for .wslconfig
the .wslconfig file configures settings globally for all linux distributions running with wsl 2.(for per-distribution configuration seewsl.conf).
see.wslconfigfor info on where to store the .wslconfig file.
note
global configuration options with.wslconfig
is only available for distributions running as wsl 2 in windows build 19041 and later. keep in mind you may need to runwsl --shutdown
to shut down the wsl 2 vm and then restart your wsl instance for these changes to take affect.
this file can contain the following options that affect the vm that powers any wsl 2 distribution:
section label:[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. |
entries with thepath
value must be windows paths with escaped backslashes, e.g:c:\\temp\\mycustomkernel
entries with thesize
value must be a size followed by a unit, for example8gb
or512mb
.
entries with an * after the value type are only available on windows 11.
example .wslconfig file
the.wslconfig
sample file below demonstrates some of the configuration options available. in this example, the file path 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 配置 修改的文章就介绍到这了,更多相关docker中 wsl 配置 修改内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!