Scenes
The Windows 10 wsl 2 version of Docker is installed on the C drive by default, and the data is stored in C:\Users\current user name\AppData\Local\Docker\wsl\data\ext4.vhdx For a long time, the space usage of the C drive will increase. Come bigger, to solve this problem we can move data to other hard drive
Docker switch data storage location operation
- stop Docker
Open the cmd window and check the stop status
C:\Users\Administrator> wsl --list -v NAME STATE VERSION * docker-desktop Running 2 docker-desktop-data Running 2
Backup and export existing data
Because the backup command does not output a progress bar, you can first check the used space (the location is at the beginning of the article), and have an estimated consumption time in mind when backing up
C:\Users\Administrator> wsl --export docker-desktop-data "F:\Docker\wsl\data\docker-desktop-data.tar" C:\Users\Administrator> dir F:\Docker\wsl\data\ 目录: D:\Docker\wsl\data Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 2020/11/25 8:54 2159349760 docker-desktop-data.tar
Command description: Back up the existing data to the F:\Docker\wsl\data\ directory and name it docker-desktop-data.tar
delete old data
C:\Users\Administrator> wsl --unregister docker-desktop-data 正在注销... C:\Users\Administrator> wsl --list -v NAME STATE VERSION * docker-desktop Stopped 2
Import data to new disk
C:\Users\Administrator> wsl --import docker-desktop-data "F:\Docker\wsl\data" "F:\Docker\wsl\data\docker-desktop-data.tar" --version 2 C:\Users\Administrator> wsl --list -v NAME STATE VERSION * docker-desktop Stopped 2 docker-desktop-data Stopped 2
Description: Import the backup data to a new virtual disk, and specify the storage path of the virtual disk as
F:\Docker\wsl\data
. After the import is completed, there will be a virtual disk path ofext4.vhdx
in this directory.start Docker
Find docker in the start menu and click start
The last backup file
F:\Docker\wsl\data\docker-desktop-data.tar
can be deleted according to the situation
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。