Motivation
By default, the
ext4.vhdx
image file of docker is stored under C:\Users\[username]\AppData\Local\Docker\wsl\data\ext4.vhdx
It takes plenty of spaces so weโd like to migrate it to somewhere else, like
G:\
.Steps
1. Shut down docker process
check WSL running status:
wsl --list -v
Shut down docker (along with all other WSL distributions)
wsl --shutdown
ย
2. Backup data
Backup the original
ext4.vhdx
to somewhere you like, e.g., "G:\WSL\data\docker-desktop-data.tar"
wsl --export docker-desktop-data "G:\WSL\data\docker-desktop-data.tar"
3. Delete original image
wsl --unregister docker-desktop-data
ย
4. Import data and specify new directory to store image
wsl --import docker-desktop-data "G:\WSL\data" "G:\WSL\data\docker-desktop-data.tar" --version 2
ย
Done ๐