【WSL】安装WSL和Docker-20220828

参考

https://docs.microsoft.com/zh-cn/windows/wsl/install
https://docs.microsoft.com/zh-cn/windows/wsl/setup/environment

打开管理员 PowerShell输入此命令

wsl --list --online
wsl --install -d Ubuntu-20.04

PS C:\WINDOWS\system32> wsl --list --online
以下是可安装的有效分发的列表。
请使用“wsl --install -d <分发>”安装。

NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS
PS C:\WINDOWS\system32> wsl --install -d Ubuntu-20.04
正在下载: Ubuntu 20.04 LTS
正在安装: Ubuntu 20.04 LTS
已安装 Ubuntu 20.04 LTS。
正在启动 Ubuntu 20.04 LTS…

WSL自动启动

输入账号和密码
手动更新sudo apt update
手动更新apt list --upgradable

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: season
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 20.04 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Aug 28 12:03:17 CST 2022

  System load:    0.52      Processes:              7
  Usage of /home: unknown   Users logged in:        0
  Memory usage:   82%       IPv4 address for eth1:  172.21.16.1
  Swap usage:     1%        IPv4 address for wifi0: 192.168.31.237

0 updates can be installed immediately.
0 of these updates are security updates.


The list of available updates is more than a week old.
To check for new updates run: sudo apt update


This message is shown once once a day. To disable it please create the
/home/season/.hushlogin file.
season@DESKTOP-25N1E20:~$ sudo apt update



278 packages can be upgraded. Run 'apt list --upgradable' to see them.
season@DESKTOP-25N1E20:~$ apt list --upgradable

检查正在运行的 WSL 版本

wsl -l -v

PS C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  docker-desktop         Running         2
  Ubuntu-20.04           Running         1

VS code打开WSL

在这里插入图片描述
WSL文件夹可以在windows中访问。
在这里插入图片描述

将WSL1升级到WSL2

wsl --set-version Ubuntu-20.04 2

  Ubuntu-20.04           Running         1
PS C:\WINDOWS\system32> wsl --set-version Ubuntu-20.04 2
正在进行转换,这可能需要几分钟时间...
有关与 WSL 2 的主要区别的信息,请访问 https://aka.ms/wsl2
转换完成。
PS C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  docker-desktop         Running         2
  Ubuntu-20.04           Stopped         2
PS C:\WINDOWS\system32> wsl -l -v
  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  docker-desktop         Running         2
  Ubuntu-20.04           Running         2

安装docker

启动docker

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

sudo service docker start

运行docker命令

docker pull seasonzhang/gaga_meeting:0.9.1
docker run --name gaga_meeting -p 8000:8000 seasonzhang/gaga_meeting:0.9.1

成功进入django debug模式
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值