Tranfer Docker Desktop to another drive

If you want to setup Docker Desktop and have your Ubuntu image you installed from the Microsoft Store off of your SSD and onto your HDD, here are some steps I put together and performed.

Disclaimer: This is an honest effort to transfer an image successfully. Always backup and do research before removing and deleting things.

First, uninstall Docker Desktop (back up etc..)
Second, remove the three main directories for \Docker\ and \DockerDesktop\

del /s /q C:\Users\<username>\AppData\Local\Docker\*
rmdir /s /q C:\Users\<username>\AppData\Local\docker\

del /s /q C:\ProgramData\DockerDesktop\*
rmdir /s /q C:\ProgramData\DockerDesktop\

del /s /q C:\ProgramData\Docker\*
rmdir /s /q C:\ProgramData\Docker\

Third, Link these directories to your new location

mklink /j "C:\Users\<username>\AppData\Local\Docker" "E:\wsl\docker\appdata_Docker"
mklink /j "C:\ProgramData\Docker" "E:\wsl\docker\programdata_Docker"
mklink /j "C:\ProgramData\DockerDesktop" "E:\wsl\docker\dockerDesktop"

4th, install docker desktop
feel free to check your logs : C:\Users\AppData\Local\Docker\

5th, install Ubuntu from the Microsoft Store
Install ubuntu and it puts it in some ugly location above.

6th, open powershell and lets stop wsl and confirm its stopped

wsl --shutdown
wsl --list -v

7th, lets back up our image, and go 2 extra steps to confirm no corruption before unregister your current image.

wsl --export Ubuntu "E:\wsl\temp\ubuntu_backup.tar"

if you run into issues check these out:

8th, check number 1 for corruption on the export

double check with 7-zip that you can open archive (make sure its not corrupt)

9th, to go another step into making sure this works we will first import the backup to a new name instead of Ubuntu, and after we confirm its good we will delete the rest

wsl --import UbuntuNew "E:\wsl\docker\wsl\Ubuntu" "E:\wsl\temp\ubuntu_backup.tar" --version 2

10th, if you really want you can now unregister both images, and re-do for the ‘Ubunutu’ image name, but I am going to keep my UbunutuNew so I set it to my default

wsl --setdefault UbuntuNew
wsl --list

11th, hopefully you are now safe to un-register your image

wsl --unregister Ubuntu

12th, I think your safe to remove this, but I could be wrong.


13th, You can set your default username back to what you made it when you installed the Ubuntu image from the microsoft store

Function WSL-SetDefaultUser ($distro, $user) { Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq $distro | Set-ItemProperty -Name DefaultUid -Value ((wsl -d $distro -u $user -e id -u) | Out-String); };

WSL-SetDefaultUser UbuntuNew babylon

There you have it, all of your docker and your WSL image on your HDD instead of your SSD

Leave a Reply

Your email address will not be published. Required fields are marked *