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

 更新时间:2021年12月28日 11:36:42   作者:PanPan003  
这篇文章主要介绍了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.wslconfigis only available for distributions running as WSL 2 in Windows Build 19041 and later. Keep in mind you may need to runwsl --shutdownto 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 thepathvalue must be Windows paths with escaped backslashes, e.g:C:\\Temp\\myCustomKernel

Entries with thesizevalue must be a size followed by a unit, for example8GBor512MB.

Entries with an * after the value type are only available on Windows 11.

Example .wslconfig file

The.wslconfigsample 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 配置 修改内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Docker镜像拉取报错:Error response from daemon: Get https://registry-1.docker.io/v2/的问题解决

    Docker镜像拉取报错:Error response from daemon: 

    这篇文章主要介绍了Docker镜像拉取报错:Error response from daemon: Get https://registry-1.docker.io/v2/的问题解决,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2023-07-07
  • Docker AIGC等大模型深度学习环境搭建步骤最新详细版

    Docker AIGC等大模型深度学习环境搭建步骤最新详细版

    这篇文章主要介绍了Docker AIGC等大模型深度学习环境搭建步骤最新详细版,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2023-05-05
  • Docker镜像分层的原理详解

    Docker镜像分层的原理详解

    这篇文章主要介绍了Docker镜像分层的原理详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-12-12
  • docker之点到点的容器网络的配置

    docker之点到点的容器网络的配置

    本篇文章主要介绍了docker之点到点的容器网络的配置,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-03-03
  • Docker一行命令完成FTP服务搭建的实现

    Docker一行命令完成FTP服务搭建的实现

    这篇文章主要介绍了Docker一行命令完成FTP服务搭建的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-09-09
  • docker搭建memcached的详细步骤

    docker搭建memcached的详细步骤

    Memcached 是一个通用的分布式内存缓存系统,它通常用于通过在 RAM 中缓存数据和对象来加速动态数据库驱动的网站,以减少必须读取外部数据源(例如数据库或 API)的次数,这篇文章主要介绍了docker搭建memcache,需要的朋友可以参考下
    2022-07-07
  • 使用 docker 部署 APISIX的详细介绍

    使用 docker 部署 APISIX的详细介绍

    这篇文章主要介绍了使用 docker 部署 APISIX的相关知识,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-03-03
  • 2023年windows DockerDeskTop最新款4.18.0 全程保姆级安装图文教程

    2023年windows DockerDeskTop最新款4.18.0 全程保姆级安装图文教程

    这篇文章主要介绍了2023年windows DockerDeskTop最新款4.18.0 全程保姆级安装图文教程,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2023-04-04
  • Docker 环境运行 Mysql 和开启 Binlog 配置主从同步的设置方法

    Docker 环境运行 Mysql 和开启 Binlog 配置主从同步的设置方法

    今天给大家分享Docker 环境运行 Mysql 和开启 Binlog 配置主从同步的设置方法,利用docker模拟mysql设置的主从同步,通过两种方式给大家介绍的非常详细,需要的朋友参考下吧
    2021-06-06
  • docker上部署MySQL的示例

    docker上部署MySQL的示例

    这篇文章主要介绍了docker上部署MySQL的示例,帮助大家更好的理解和学习使用docker,感兴趣的朋友可以了解下
    2021-04-04

最新评论