Get the App
SLTechnology News&Howtos  ›  Development  › 

How to make the tar file of wsl through Docker

Shulou Source: shulou.com Published: 2022-06-03 09:40:35 11月15日 Update

This article will explain in detail how to make wsl tar files through Docker. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Recently play VScode remote development function, it can connect Docker container, can also connect wsl,window under the container is running in WSL, then study the direct connection to WSL, and not let Docker this second-hand merchants earn the difference, hehe.

Through the wsl-l-o command, we can see the list of images that can be installed remotely.

Download the image through Microsoft Store is always unable to download, the command line is not good, maybe there is something wrong with the network here (sometimes it can be downloaded, (╯ '□') ╯ download ┻━┻), according to the official website tips, you can use docker to create a tar file and import it into wsl, WSL document, and I also want to install a CentOS to try.

No one runs the operating system just to run the operating system

# pull centos image docker pull centos# to create containers, docker run-it centos# list all containers find centOS containers IDdocker container ls-a # Export distribution docker export c9e89339e9d2 > e:\ centos.tar# import distribution to wsl Command format wsl-- import # remember to create the corresponding folder wsl-- import CentOS E:\ wslDistroStorage\ CentOS e:\ centos.tar# to view the installed wsl wsl-l-v# startup and access to the system wsl-d CentOS# completed, # extension, specify the default distribution, wsl-- setdefault (- s) wsl-s CentOS# specify the default distribution, you can enter it directly, and wsl will enter CentOS by default.

OK complete.

Move the location of the wsl C:\ Users\ Administrator > wsl-- l-v NAME STATE VERSION* docker-desktop Running 2 docker-desktop-data Running export, export the wsl to the specified file C:\ Users\ Administrator > wsl-- export docker-desktop-data "D:\ Docker\ wsl\ data\ docker-desktop-data.tar" # remove the original virtual machine After deletion, all information will be cleared C:\ Users\ Administrator > wsl-- unregister docker-desktop-data # generate a new virtual machine, that is, import the virtual machine at the specified location.-- version 2 is the version of the specified wsl #, if wsl2 has been set to the default value, then you do not need to specify it again. # if there are no special requirements, use the new one. C:\ Users\ Administrator > wsl-- import docker-desktop-data "D:\ Docker\ wsl\ data"D:\ Docker\ wsl\ data\ docker-desktop-data.tar"-- version 2docker

Rename docker Container

Docker rename newName on "how to make wsl tar files through Docker" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: File container production command article system image run operating system location more release no good practical special information content function again Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Linux macOS vpn Docker