Wsl2安装CentOS7

Wsl2安装CentOS7

(或任何你想安装的Linux发行版)

前提条件:安装了虚拟机,且安装好了Docker

  1. 找到你想要的CentOS版本 CentOS的DockerHub地址

  2. 下载docker镜像(我这里是因为已经下载好了,所以显示的结果是这样)

    [root@localhost128 ~]# docker pull centos:centos7
    centos7: Pulling from library/centos
    Digest: sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
    Status: Image is up to date for centos:centos7
    docker.io/library/centos:centos7
    
  3. 查看已经下载好的镜像

    [root@localhost128 ~]# docker images
    REPOSITORY               TAG             IMAGE ID       CREATED         SIZE
    centos                   centos7         8652b9f0cb4c   9 months ago    204MB
    
  4. 启动centos并查看启动后的容器

    [root@localhost128 ~]# docker run centos:centos7
    [root@localhost128 ~]# docker ps -a
    CONTAINER ID   IMAGE            COMMAND       CREATED         STATUS              
    44604d80ea3a   centos:centos7   "/bin/bash"   9 seconds ago   Exited (0) 7 seconds ago      
    
  5. 导出刚刚启动的容器

    [root@localhost128 ~]# docker export 44604d80ea3a >  centos7.tar
    [root@localhost128 ~]# ls
    anaconda-ks.cfg  centos7.tar
    
  6. 把刚刚导出的容器下载到本地电脑上

  7. 安装刚刚导出的CentOS7 Wsl2命令文档

    wsl --import  centos7  D:\Linux\CentOS7   D:\Linux\centos7.tar
    

导出centos7.tar包过程截图

posted @ 2023-02-12 20:26  菜阿  阅读(379)  评论(0编辑  收藏  举报