type
Post
status
Published
date
May 16, 2024
slug
summary
tags
技术
category
icon
password
😀
windows下有时想使用Linux,因为工作大部分场景是Linux系统,今天找了一下windows如何同时运行Linux操作系统,使用WSL,如果没有wsl命令就进行安装wsl
 

📝 安装Linux系统

安装wsl已有的操作系统

wsl --list --online 查看有那些系统
notion image
wsl --install -d Ubuntu-20.04 选择版本安装,提示设置用户名/密码
notion image

自建系统

这里没有centos,但又想用centos的可以通过docker镜像导入在通过wsl启动 启动docker拉取对应docker版本镜像 我使用的桌面版的,直接搜索,拉取centos7
notion image
打开cmd启动,桌面版直接运行不知道为什么启动不了也没有日志输出,所以直接用命令默认启动,
docker run -t centos:centos7
启动后在新的cmd窗口或docker桌面中查看
docker ps
notion image
notion image
找到启动容器cp容器id
docker export 容器id > E:\docker-images\centos7.tar
将导出的镜像倒入wsl中[wsl --import <Distro> <InstallLocation> <FileName>]
wsl --import CentOS7 E:\centos7 E:\docker-images\centos7.tar
wsl查看
wsl -l -v
notion image
启动
wsl -d CentOS7
notion image
 

🤗 总结归纳

可以在windows中更方便允许linux操作系统,docker有时网络配置漏了比较麻烦,而这种方式就像直接操作机器一样

📎 参考文章

 
💡
有关问题,欢迎您在底部评论区留言,一起交流~
CentOS安装nginx多久没和人家闲聊了
Loading...