Docker Desktop is the common GUI client for Docker on Windows, but its installation and storage settings are not very transparent by default.
This post summarizes practical steps to change the Docker Desktop install path, migrate WSL distributions, and move Docker data storage to reduce C drive pressure.
Changing Docker Desktop Installation Directory
First, download Docker Desktop. In fact, the official Docker documentation explains how to manually set its installation directory. However, when searching online, I found that very few sources mention this—I actually stumbled upon it in a reply under a Zhihu post. Many online tutorials suggest "swapping" its installation path by creating symbolic links; I have not tried this method and do not know how reliable it is. The official method, however, works perfectly.
The official approach is to install via the command line. So after downloading the official installer .exe, do not rush to double-click and open it. Open CMD and navigate to the directory where your installer is located. The command-line installation supports various flags for configuration (I'm not sure why basic features like changing installation paths or setting download proxies are not exposed in the GUI). Here is the command to change the installation path:
1 |
|
1 |
|
For other parameter commands, check the Official Manual.
Changing WSL System Directory
Windows places the virtual disk environment for WSL (Windows
Subsystem for Linux) on drive C by default. Consequently, Docker's
storage directory when using WSL is also located on drive C, typically
at:
C:\Users\<Username>\AppData\Local\Docker\wsl\data\ext4.vhdx.
If it is Docker's WSL directory, you can actually configure it during
installation using the command-line parameters mentioned above. If it is
already installed, it can still be moved, and this method applies to
changing the directory of any WSL subsystem.
wsl --list -v to view the installed
distributions and their status, for example:
1 |
|
Remember the version number (VERSION) of
the distro you want to move. If it is currently running, shut it down
using wsl --shutdown. Here, we take moving Docker's system
data as an example. What we need to move is the
docker-desktop-data distro (Please note: do NOT modify
the docker-desktop distro!).
First, back up the distro that needs to be moved.
1
wsl --export docker-desktop-data "<directory_to_save_backup_tar(arbitrary)>\docker-desktop-data.tar"This step packs the entire distro into a temporary archive, which will later be used to restore the system.
Then, unregister the distro at its original location.
1
wsl --unregister docker-desktop-dataFinally, specify the new target directory and restore the backed-up distro:
1
wsl --import docker-desktop-data "<target_directory_to_move_to>" "<directory_where_backup_tar_was_saved>\docker-desktop-data.tar" --version <VERSION_number_checked_earlier>
Once finished, the directory migration is complete—finally freeing up the system drive Ꮚ・ꈊ・Ꮚ.