设为首页收藏本站

安徽论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 10872|回复: 0

关于docker中 WSL 配置与修改问题

[复制链接]

63

主题

503

回帖

953

积分

高级会员

Rank: 4

积分
953
发表于 2022-3-26 10:58:46 | 显示全部楼层 |阅读模式
网站内容均来自网络,本站只提供信息平台,如有侵权请联系删除,谢谢!

https://docs.microsoft.com/en-us/windows/wsl/wsl-config
.wslconfig

       
  • Stored in your
    1. %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
    1. %UserProfile%
    复制代码
    directory, in PowerShell, use
    1. cd ~
    复制代码
    to access your home directory (which is typically your user profile,
    1. C:\Users\<UserName>
    复制代码
    ) or you can open Windows File Explorer and enter
    1. %UserProfile%
    复制代码
    in the address bar. The directory path should look something like:
    1. 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
  1. .wslconfig
复制代码
is only available for distributions running as WSL 2 in Windows Build 19041 and later. Keep in mind you may need to run
  1. wsl --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:
  1. [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 the
  1. path
复制代码
value must be Windows paths with escaped backslashes, e.g:
  1. C:\\Temp\\myCustomKernel
复制代码
Entries with the
  1. size
复制代码
value must be a size followed by a unit, for example
  1. 8GB
复制代码
or
  1. 512MB
复制代码
.
Entries with an * after the value type are only available on Windows 11.
Example .wslconfig file

The
  1. .wslconfig
复制代码
sample file below demonstrates some of the configuration options available. In this example, the file path is
  1. C:\Users\<UserName>\.wslconfig
复制代码
.
  1. # Settings apply across all Linux distros running on WSL 2
  2. [wsl2]

  3. # Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
  4. memory=4GB

  5. # Sets the VM to use two virtual processors
  6. processors=2

  7. # 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
  8. kernel=C:\\temp\\myCustomKernel

  9. # Sets additional kernel parameters, in this case enabling older Linux base images such as Centos 6
  10. kernelCommandLine = vsyscall=emulate

  11. # Sets amount of swap storage space to 8GB, default is 25% of available RAM
  12. swap=8GB

  13. # Sets swapfile path location, default is %USERPROFILE%\AppData\Local\Temp\swap.vhdx
  14. swapfile=C:\\temp\\wsl-swap.vhdx

  15. # Disable page reporting so WSL retains all allocated memory claimed from Windows and releases none back when free
  16. pageReporting=false

  17. # Turn off default connection to bind WSL 2 localhost to Windows localhost
  18. localhostforwarding=true

  19. # Disables nested virtualization
  20. nestedVirtualization=false

  21. # Turns on output console showing contents of dmesg when opening a WSL 2 distro for debugging
  22. debugConsole=true
复制代码
到此这篇关于docker中 WSL 配置 修改的文章就介绍到这了,更多相关docker中 WSL 配置 修改内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
                                                        
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
免责声明
1. 本论坛所提供的信息均来自网络,本网站只提供平台服务,所有账号发表的言论与本网站无关。
2. 其他单位或个人在使用、转载或引用本文时,必须事先获得该帖子作者和本人的同意。
3. 本帖部分内容转载自其他媒体,但并不代表本人赞同其观点和对其真实性负责。
4. 如有侵权,请立即联系,本网站将及时删除相关内容。
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表