While installing Docker on Windows typically forces it onto your C: drive, many developers run out of space as images and containers grow. This guide shows you how to bypass the GUI and use CLI flags to install Docker Desktop in a custom location (e.g., D:\Docker) while also moving the heavy WSL2 data roots.
TL;DR: To save your C: drive from Docker’s growing appetite, bypass the GUI installer. Open PowerShell as Admin and run:
start /w "" "Docker Desktop Installer.exe" install --accept-license --installation-dir="D:\Docker" --wsl-default-data-root="D:\Docker\wsl"
Requirements for Custom Installation
To ensure a smooth migration to another drive, verify you meet these criteria:
- OS: Windows 10 or 11 (with Hyper-V and WSL 2 enabled).
- Installer: The latest Docker Desktop
.exedownloaded here. - Permissions: Administrator access.
- Storage: A secondary drive (D:, E:, etc.) with at least 64GB of free space (SSD recommended for performance).
Preparation
- Create Folders: Create your target directory. For example:
D:\Containers. - Cleanup: If you have an existing Docker installation, back up your volumes and uninstall it first.
- Stop Services: Open PowerShell as admin and run
sc.exe stop dockerto ensure no locks are active.
Recommended Directory Structure
For a clean setup, use a structure like this on your secondary drive:
1D:\CONTAINERS
2├───docker (App files)
3└───wsl (Linux container data)
4└───windows-data (Windows Container Data)Step-by-Step Installation via CLI
The GUI installer doesn’t offer a “Browse” button for the path. You must run it from the command line (PowerShell or CMD) with specific flags.
The Complete Command:
1start /w "" "Docker Desktop Installer.exe" install --accept-license \
2--installation-dir="D:\Containers\docker" \
3--wsl-default-data-root="D:\Containers\wsl" \
4--windows-containers-default-data-root="D:\Containers\windows-data"Flag Explanations:
--installation-dir: Moves the actual Docker application binaries (usuallyC:\Program Files\Docker\Docker).--wsl-default-data-root: The most important flag. This moves the massiveext4.vhdxfiles where your Linux containers actually live.--windows-containers-default-data-root: Moves the data root for Windows-native containers.
Note: Replace D:\Containers with your actual drive letter.
Post-Installation & Verification
- Restart your computer to ensure all registry changes and WSL paths are initialized.
- Verify paths: Open PowerShell and run:
powershell
1docker info | select-string "Docker Root Dir" - Check WSL: Verify the data is being stored in your new location by checking the folder size of your
wsldirectory after pulling a few large images.
Why move Docker to another drive?
- Performance: Offloading I/O to a dedicated SSD can prevent OS lag during heavy builds.
- Stability: Prevents “Disk Full” errors that can crash Windows when Docker pulls large image layers.
- Organization: Keeps your system drive lean and focused strictly on the OS.
Stop fighting your tools. If you found this useful, join the Dispatch—a weekly deep dive into the mechanics of high-performance systems, Go internals, and devops architecture.