1、BIOS开启虚拟化
- 查看任务管理器中虚拟化是否开启
- 虚拟化启用
BISO环境进行虚拟化开启参考链接
2、添加Hyper-V(家庭版)
- 将下面内容复制到文件中,命名为Hyper-V.cmd,然后已管理员身份运行,直到安装成功,最后输入Y即可
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
- 运行过程中截图
3、启用Hyper-V
windows打开搜索栏,输入:启用或关闭Windows功能。Hyper-V进行勾选
4、检查WSL并更新
- 在终端cmd窗口输入,如果报错则没安装
wsl -l
- 安装wsl(安装了则不需要执行)
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
注意:斜体样式安装完成后必须重启!
- 检验wsl是否安装成功
再次打开终端cmd输入下面命令,不报错则证明安装成功
wsl -l
- 将安装的Linux子系统版本设置为WSL2
终端cmd输入
wsl.exe --set-default-version 2
出现下图则证明设置成功
5、安装Docker-desktop
- 下载地址
- 选择windows版本下载
- DockerDesktop基础配置
我们需要开启至少这两个选项,其他默认或者开启,作用请自己翻译 - DockerDesktop镜像配置
我们配置一下镜像源,国外的官方源太慢了
镜像内容如下:
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://dockermirrors.uste.edu.cn",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://mirror.ccs.tencentyun.com"
]
}
使用(示例:使用docker搭建redis服务)
- 下载最新redis镜像
docker pull redis
- 启动(Docker-desktop启动)
- 客户端验证redis已启动