下载网址:https://docs.docker.com/desktop/windows/install/
启动WSL。用管理员身份打开PowerShell,然后在PowerShell中,输入下面的命令。
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
下载地址:https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
一路点击就好。
wsl --set-default-version 2
打开 Microsoft Store,搜索 Terminal,安装 Windows Terminal,用于后面和 WSL 子系统交互。
安装完成后,第一次打开 Ubuntu 的时候,将打开一个控制台窗口,会等待几分钟来进行配置,启动完成后为 Ubuntu 创建一个用户和密码
备份安装源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
修改sources.list安装源到国内镜像
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
保存退出后更新软件列表
apt update && apt upgrade -y
双击下载的 Docker for Windows Installer 安装文件,一路 Next,点击 Finish 完成安装。
查看docker版本
docker --version
接下来我们给Docker配置镜像加速器,我们鼠标右键点击docker的图标,选择Settings,在Daemon处的Registry mirrors,安装上面的eg例子,添加镜像加速器,然后点击Apply按钮。此时会提示Docker Desktop正在启动,过一会提示启动完成。