wsl如何升级到wsl2
reference:https://docs.microsoft.com/zh-cn/windows/wsl/tutorials/wsl-containers
https://docs.docker.com/docker-for-windows/wsl/
https://docs.microsoft.com/zh-cn/windows/wsl/reference
https://docs.docker.com/docker-for-windows/install-windows-home/
https://www.cnblogs.com/temari/p/13188168.html
https://github.com/microsoft/WSL/discussions/5922
docker run -it ubuntu bash 这个镜像最小化了,需要运行
win10家庭版开启虚拟化
docker-for-windows需要开启hyper-v
https://docs.docker.com/docker-for-windows/troubleshoot/#hyper-v
win10 home版如何安装与禁止hyper-v
How To Enable Hyper-V On Windows 10 Home (itechtics.com) 下载的脚本内容如下
1 | pushd "%~dp0" |
按住windows键,输入Hyper-V,显示Hyper-V管理器
wsl1切换到wsl2
wsl和wsl2可以互相切换,切换到wsl2后,不需要重新安装disto,docker Desktop for windows只支持wsl2,为了在win10家庭版下使用docker,需要进行切换
To check the WSL mode, run:
1 | wsl.exe -l -v |
To upgrade your existing Linux distro to v2, run:
1 | wsl.exe --set-version (distro name) 2 |
To set v2 as the default version for future installations, run:
1 | wsl.exe --set-default-version 2 |
运行wsl.exe --set-version (distro name) 2
需要几分钟,此时wsl已经切换到wsl2,然后运行
wsl --distribution (distro name)
启动wsl2的disto(不需要再重新安装:wsl install (distro name) )
运行docker run hello-world
测试是否正常,如果出现”Unable to find image 'hello-world:latest' locally
“,是因为docker还没有从hub上pull镜像到本地,稍等下就可以了
列出所有安装的image
docker image ls
运行某个镜像
docker run image-name
docker替换源
docker在不同平台替换源的配置方式不同,参考dockerd | Docker Documentation,搜索configuration file
可以找到windows平台的配置方式
docker官方推出了中国源:
1 | "registry-mirrors": [ |
docker-desktop-for-windows的config file
位于C:\Users\hcf\AppData\Roaming\Docker\last-start-linux-daemon.json
或者C:\Users\hcf\.docker\daemon.json 这两个文件内容一致