How can I change the location of docker images when using Docker Desktop on WSL2 with Windows 10 Home?
The WSL 2 docker-desktop-data vm disk image would normally reside in:%USERPROFILE%\AppData\Local\Docker\wsl\data\ext4.vhdx
Follow the following to relocate it to other drive/directory, with all existing docker data preserved (tested against Docker Desktop 2.3.0.4 (46911), and continued to work after updating the 3.1.0 (51484)):
First, shut down your docker desktop by right click on the Docker Desktop icon and select Quit Docker Desktop
Then, open your command prompt:
wsl --list -v
You should be able to see, make sure the STATE for both is Stopped.(wsl --shutdown
)
NAME STATE VERSION
* docker-desktop Stopped 2
docker-desktop-data Stopped 2
Export docker-desktop-data into a file
wsl --export docker-desktop-data "D:\Docker\wsl\data\docker-desktop-data.tar"
Unregister docker-desktop-data from wsl, note that after this, your ext4.vhdx
file would automatically be removed (so back it up first if you have important existing image/container):
wsl --unregister docker-desktop-data
Import the docker-desktop-data back to wsl, but now the ext4.vhdx would reside in different drive/directory:
wsl --import docker-desktop-data "D:\Docker\wsl\data" "D:\Docker\wsl\data\docker-desktop-data.tar" --version 2
Start the Docker Desktop again and it should work
You may delete the D:\Docker\wsl\data\docker-desktop-data.tar
file (NOT the ext4.vhdx
file) if everything looks good for you after verifying
Windows 10 WSL - Maven config
Found a possible solution.
I created a symbolic link from ~/.m2
to /mnt/c/Users/<username/.m2
Command: $ ln -s /mnt/c/Users/<username>/.m2 ~/.m2
Until the moment is working fine.
How do I backup and restore my files/permissions when preparing for a remove/replace of WSL?
Just use linux way to backup your files with permission, such as getfacl/setfacl
or tar -p
Related Topics
Specifying Non-Standard Baud Rate for Ftdi Virtual Serial Port Under Linux
How to Find Words from One File in Another File
Comparing Two Files in Linux Terminal
Bash Scripting - How to Set the Group That New Files Will Be Created With
Expression After Last Specific Character
How to Find Files Modified in Last X Minutes (Find -Mmin Does Not Work as Expected)
Rm: Cannot Remove: Permission Denied
How to Chmod 0777 a File and Commit as Is to Git on Windows
Distributing Binary Applications Across Linux Distros
What's the Difference Between ./Script.Sh and Bash Script.Sh
How to Pass Shell Variables as Command Line Argument to a Shell Script
Create a Symbolic Link of Directory in Ubuntu
Why Docker Has Ability to Run Different Linux Distribution
Parameter for Shell Scripts That Is Started with Qsub
How to Find Files That Only Have Certain Permission for Owner