展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

wsl安装、配置


  • 设置 -> 系统 -> 关于 -> 确保运行的是 Windows 版本 16215 或更高版本

  • microsoft store方式安装

# 官方参考:https://docs.microsoft.com/zh-cn/windows/wsl/install-manual
# 参考:https://zhuanlan.zhihu.com/p/386590591
# 安装步骤:使用命令安装wsl linux内核,再打开Microsoft Store安装linux分发版
# 分发版安装后输入用户名和密码
# 报错(用户名只能小写):adduser - “Failed to create user” due to regular expression error - Ask Ubuntu
  • 命令方式安装
# 官方参考:https://docs.microsoft.com/zh-cn/windows/wsl/install
# 管理员身份打开powershell,安装内核
wsl --install
# 查看发行版,安装发行版
wsl -l -o
wsl --install -d Ubuntu
  • 手动下载Linux发行版
# 参考:https://www.cnblogs.com/aymar/p/14522403.html

# 安装内核,下载发行版,双击发行版直接安装
# 安装完成后设置用户名和密码
  • 设置root密码
sudo passwd root
  • 设置源
# 备份配置文件
cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 编辑配置文件
vim /etc/apt/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

# 更新时报错:Err:1 http://mirrors.aliyun.com/ubuntu xenial InRelease Temporary failure 

# 更改dns
sudo vi /etc/resolv.conf
# 将nameserver 127.0.0.53改为如下:
nameserver 8.8.8.8
nameserver 8.8.4.4

# 参考:https://www.cnblogs.com/ellen-mylife/p/14681022.html
  • 安装docker
# 安装curl
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
    
# 添加docker源
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
   
sudo apt-get update

# 安装docker
sudo apt-get install docker-ce

# 验证是否安装成功
docker version
docker -v

# 启动docker,之后就可以拉取镜像了
sudo service docker start

# 参考:https://blog.csdn.net/weixin_36182972/article/details/104898438
  • 报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
# 解决方案:以管理员的身份打开wsl,之后以管理员的身份root登录wsl
posted @ 2022-07-22 10:54  DogLeftover  阅读(162)  评论(0编辑  收藏  举报