安装

参考: https://zhuanlan.zhihu.com/p/61542198

  • 在微软商店安装

3610b18db842f46f0875dced01265c5.png

配置

修改根目录位置

参考: https://blog.csdn.net/Tiezhu_Wang/article/details/120588669

  1. Microsoft Windows [版本 10.0.19044.1645]
  2. (c) Microsoft Corporation。保留所有权利。
  3. C:\Users\Administrator>wsl -l -v
  4. NAME STATE VERSION
  5. * Ubuntu-20.04 Running 2
  6. C:\Users\Administrator>wsl --export Ubuntu D:\u.tar
  7. 不存在具有提供的名称的分布。
  8. C:\Users\Administrator>wsl --export Ubuntu-20.04 D:\u.tar
  9. C:\Users\Administrator>wsl --unregister Ubuntu-20.04
  10. 正在注销...
  11. C:\Users\Administrator>wsl --import Ubuntu-20.04 d:/ubuntu d:u.tar --version 2
  12. C:\Users\Administrator>Ubuntu config --default-user root
  13. Installing, this may take a few minutes...
  14. Please create a default UNIX user account. The username does not need to match your Windows username.
  15. For more information visit: https://aka.ms/wslusers
  16. Enter new UNIX username: root
  17. adduser: The user `root' already exists.
  18. Enter new UNIX username: xinzhang
  19. New password:
  20. Retype new password:
  21. passwd: password updated successfully
  22. Installation successful!
  23. C:\Users\Administrator>

搞定过后实际中间还有一层
image.png

修改为国内软件源

  1. sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
  2. sudo sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
  3. apt-get update

软件安装

docker

参考: https://docs.docker.com/engine/install/debian/

  1. 安装docker-desktop

官网: https://www.docker.com/products/docker-desktop/
image.png

  1. docker-desktop集成wsl

参考: https://blog.csdn.net/weixin_48031922/article/details/116529198
image.png
此处没有则需要先将wsl版本升级为2

  1. # 查看版本
  2. wsl -l -v
  3. # 升级版本
  4. wsl --set-version Ubuntu-20.04 2

image.png

  1. 设置阿里云镜像加速器

注册地址: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
image.png
image.png

  1. 添加几个其他的镜像加速器

参考: https://www.runoob.com/docker/docker-mirror-acceleration.html

  1. 科大镜像:https://docker.mirrors.ustc.edu.cn/
  2. 网易:https://hub-mirror.c.163.com/
  3. 阿里云:https://<你的ID>.mirror.aliyuncs.com
  4. 七牛云加速器:https://reg-mirror.qiniu.com
  1. 测试

image.png