Change Docker Default Location
Docker Desktop for Windows is great since you can switch between Linux and Windows seamlessly.
Unfortunately, during the installation, you are not offered the possibility to set the default directory. This leads to the system drive filling up sooner or later if you do a lot of experimenting.
Following how to change the default location:
Windows
Defautl location: %PROGRAMDATA%/Docker
- Stop Docker
- Create new destination on different drive
mkdir D:\Docker_Windows
- Add “data-root”: “D:\Docker_Windows” to C:\ProgramData\Docker\config\daemon.json
- Start Docker
Linux
Default location: %LOCALAPPDATA%/Docker
- Stop Docker
- Shutdown all WSL distros
wsl --shutdown
- Export docker-desktop-data to tar file
wsl --export docker-desktop-data D:\docker-desktop-data.tar
- Unregister current docker-desktop-data distro
wsl --unregister docker-desktop-data
- Import docker-desktop-data distro from tar file
wsl --import docker-desktop-data D:\Docker_WSL\data D:\docker-desktop-data.tar --version 2
- Start Docker
- Remove D:\docker-desktop-data.tar (if the import was successful)