docker storage directory migration

Reference:[Docker Special Topic] Detailed Notes on WSL Image Package Drive Letter Migration - Nuggets

docker migration


1 default directory

Windows version (Windows 10 wsl 2) docker default program is installed to the c drive, and the data is stored in This will cause the space occupied by the C drive to increase as docker usage increases. . In order to solve this problem, we generally move the data part to other disks. C:\Users\当前用户名\AppData\Local\Docker\wsl\data\ext4.vhdx

Since it has been migrated once, the current directory is:

D:\docker_data\ext4.vhdx

2. Migration directory

2.1 Exit the client

Open cmd window. View the stop status:

Windows + R

is a command used to list installed WSL (Windows Subsystem for Linux) distributions and their details. After executing this command, you will get a list of the names of installed WSL distributions, their version numbers, and whether they are running. This is useful for managing and inspecting installed Linux distributions.

wsl --list -v

2.2 Back up and export existing data

wsl --export docker-desktop-data "F:\3\docker_data\docker-desktop-data.tar"

Command instructions: Back up the existing data to the F:\3\docker_data\ directory and name it docker-desktop -data.tar

dir F:\3\docker_data\ 

View catalog

2.3. Delete original data

wsl --unregister docker-desktop-data

When you unregister a distribution, it will no longer be available in your WSL and the associated file system and configuration information will be deleted. This command is generally used to uninstall or uninstall a WSL distribution. When you unregister a distribution, it will no longer be available in your WSL and the associated file system and configuration information will be deleted.

wsl --list -v

wsl --list -vis a Windows Subsystem for Linux (WSL) command that lists the WSL distributions installed on the current computer, along with their details, including version numbers.

Note: Unmap the current docker data virtual disk. This operation will delete the original ext4.vhdx (Please operate with caution before data is not backed up)

2.4. Import data to new disk

wsl --import docker-desktop-data "F:\3\docker_data\ " "F:\3\docker_data\docker-desktop-data.tar" --version 2

The command you provided is used to import a custom distribution into Windows Subsystem for Linux (WSL). This command will import an existing distribution from the specified tar file into WSL and assign it a specified name (in this case "docker-desktop-data").

  • wsl --import docker-desktop-data "F:\3\docker_data\ " "F:\3\docker_data\docker-desktop-data.tar": This part of the command is used toimport the distribution version. Where "docker-desktop-data" is the name of the new distribution, "F:\3\docker_data\" is the path to the installation directory, "F:\3\docker_data\docker-desktop-data.tar" YesThe tar file path of the already distributed version.

  • --version 2: This option specifies WSL version 2, an upgraded version of WSL with better performance and integration.

Instructions: Import backup data into a new virtual disk, and specify the storage path of the virtual disk as F:\3\docker_data\ , after the import is completed, there will be a ext4.vhdx virtual disk path in this directory

 

2.5. Start Docker

Find docker in the start menu and click start. The migration is completed.

The last backed up file F:\3\docker_data\docker-desktop-data.tar can be deleted according to the situation.

Guess you like

Origin blog.csdn.net/March_A/article/details/134163458