How to make a tar file of wsl through Docker

How to make a tar file of wsl through Docker

I've been playing with the remote development function of VScode recently. It can connect to Docker's container and also to WSL. The container under window runs on WSL, so I'll study how to connect to WSL directly instead of letting Docker, the second-hand dealer, make a profit from the price difference.

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

insert image description here

I can never download the image through Microsoft Store, and the command line doesn't work either. It may be that there is a problem with the network here (sometimes it can be downloaded, (╯‵□′)╯︵┻━┻). According to the official website, you can use docker to make a tar file yourself and import it into wsl, WSL documentation, and I also want to install CentOS to try it.

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

# Pull the centos image docker pull centos
# Create a container,
docker run -it centos 
# List all containers and find the container ID of centOS
docker container ls -a
# Export the distribution docker export c9e89339e9d2 > e:\centos.tar
# Import the distribution to wsl, command format wsl --import <Distro> <InstallLocation> <FileName> 
# Remember to create the corresponding folder wsl --import CentOS E:\wslDistroStorage\CentOS e:\centos.tar
# View the installed wsl 
wsl -l -v
# Start and enter the system wsl -d CentOS
# Done,
# Under the extension, specify the default distribution, wsl --setdefault(-s) <DistributionName>  
wsl -s CentOS
# After specifying the default distribution, you can enter it directly, and wsl will enter the CentOS distribution by default.

OK Done.

Move the location of wsl

C:\Users\Administrator> wsl --l -v
  NAME STATE VERSION
* docker-desktop Running 2
  docker-desktop-data Running 2
# Export, export 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. All information will be cleared after deletion. 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 to specify wsl
  # version. If you have already set wsl2 as the default, you do not need to specify it again.
  # If there is no special requirement, 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 2

docker

Rename Docker container

docker rename <container id/name> newName

This is the end of this article about making wsl tar files through Docker. For more information about Docker wsl tar files, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed process of deploying Docker to WSL2 in IDEA
  • Installing Docker Desktop reports an error message: WSL 2 installation is incomplete (Solve the error message)
  • How to install WSL2 Ubuntu20.04 on Windows 10 and set up the docker environment
  • Tutorial on installing Docker in Windows 10 subsystem Ubuntu (WSL) (with pictures and text)
  • About WSL configuration and modification issues in Docker

<<:  Getting Started Tutorial on Using TS (TypeScript) in Vue Project

>>:  Setting the width of table cell td is invalid and the internal content always stretches it

Blog    

Recommend

Detailed explanation of four types of MySQL connections and multi-table queries

Table of contents MySQL inner join, left join, ri...

How to set password for mysql version 5.6 on mac

MySQL can be set when it is installed, but it see...

CSS to achieve floating customer service effect

<div class="sideBar"> <div>...

Nginx rewrite regular matching rewriting method example

Nginx's rewrite function supports regular mat...

The hottest trends in web design UI in 2013 The most popular UI designs

Time flies, and in just six days, 2013 will becom...

The most comprehensive collection of front-end interview questions

HTML+CSS 1. Understanding and knowledge of WEB st...

Introduction to Docker Quick Deployment of SpringBoot Project

1. Install Docker First open the Linux environmen...

Implementation of deploying war package project using Docker

To deploy war with Docker, you must use a contain...

The difference and execution method of select count() and select count(1)

Count(*) or Count(1) or Count([column]) are perha...

Detailed explanation of several methods of JS array dimensionality reduction

Dimensionality reduction of two-dimensional array...

MYSQL stored procedures, that is, a summary of common logical knowledge points

Mysql stored procedure 1. Create stored procedure...