How to Install Docker on Another Drive in Windows (D: Drive Guide)

Is your C: drive full? Learn how to install Docker Desktop in a custom location (like a D: drive) on Windows 10 or 11 using CLI flags for WSL2 data and container roots.

WORDS: 1502 | CODE BLOCKS: 35 | EXT. LINKS: 1

Docker Desktop on Windows installs to your C: drive by default. When you pull large images (often 1.5GB each), add build layers, and stack containers, the ext4.vhdx file that holds all your container data bloats fast. This guide shows you how to route Docker to a secondary drive entirely, using CLI flags instead of the GUI.

Quick Start

Uninstall any existing Docker first. Then open PowerShell as admin and navigate to your Downloads folder where the installer is. Run:

powershell
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"

Replace D:\Containers with your target path. Wait for the installer to finish (it won’t show a progress window), then restart Windows.


Pre-Flight Checklist

Before you start, verify your environment.

Windows version (Build 19041+):

powershell
1[System.Environment]::OSVersion.Version

Check Settings > System > About > Windows specifications to confirm.

WSL2 installed:

powershell
1wsl --list --verbose

If nothing shows, install WSL2 first: wsl --install. This installs Ubuntu by default.

Hyper-V enabled:

powershell
1Get-WindowsOptionalFeature -Online -FeatureName Hyper-V

Look for State: Enabled. If it says Disabled, enable it:

powershell
1Enable-WindowsOptionalFeature -Online -FeatureName Hyper-V -All

Then restart.

Secondary drive with 80GB+ free space:

powershell
1Get-Volume

Verify your target drive (D:, E:, etc.) is listed and has at least 80GB free. SSD is strongly recommended—VHDX files are I/O-heavy.

Admin permissions: Run PowerShell as admin. You’ll see an error immediately if you lack permissions.

On your secondary drive, create this layout:

text
1D:\Containers
2├───docker          (Docker application binaries, ~1GB)
3├───wsl              (WSL2 ext4.vhdx file, grows with images)
4└───windows-data     (Windows container data, usually empty)

Create these folders first:

powershell
1mkdir "D:\Containers\docker"
2mkdir "D:\Containers\wsl"
3mkdir "D:\Containers\windows-data"

Understanding the Flags

The --installation-dir flag moves the Docker Desktop app binaries. These are small and don’t change often.

The --wsl-default-data-root flag is the important one. It moves the ext4.vhdx file, which holds all your Linux container data. This file grows with every image pull, layer, and container you create. It’s why your C: drive fills up. This is where the space gets consumed.

The --windows-containers-default-data-root flag moves the Windows container data root. You rarely need this unless you explicitly enable Windows container mode in Docker Desktop settings.


Installation Steps

Step 1: Uninstall Existing Docker (if present)

If Docker is already installed:

powershell
1# Stop the service
2sc.exe stop docker
3
4# Uninstall via Control Panel (or CLI)
5"C:\Program Files\Docker\Docker\uninstall.exe" --quiet

Wait for the process to finish. You can verify removal:

powershell
1Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | 
2  Select-Object DisplayName | 
3  grep Docker

If nothing shows, Docker is gone.

Step 2: Navigate to the Installer

Download Docker Desktop from here. You’ll get Docker Desktop Installer.exe. Move it to an easy location (e.g., C:\Users\YourUsername\Downloads) so the command below works.

Then, open PowerShell as admin and navigate to the folder:

powershell
1cd C:\Users\YourUsername\Downloads

Step 3: Run the Installer with Flags

powershell
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"

The start /w waits for the installer to finish. You won’t see a progress window, so the command will hang silently for 2-5 minutes depending on disk speed. This is normal and expected.

If it fails, skip to the Troubleshooting section below for solutions.

Step 4: Restart Windows

powershell
1Restart-Computer

This is critical. Registry changes and WSL mount points won’t take effect until you restart.


Verification

After restart, verify the installation worked.

Run docker info to check the installation path:

powershell
1docker info

Look for Docker Root Dir. It should show your new path:

1Docker Root Dir: D:\Containers\wsl\docker-desktop-data\mnt\wsl\docker-desktop\cli-tools

To filter just this line:

powershell
1docker info | select-string "Root Dir"

Pull a test image to ensure the system works:

powershell
1docker pull nginx:latest

Check the file size of your WSL directory to confirm data is being stored there:

powershell
1(Get-ChildItem -Path "D:\Containers\wsl" -Recurse | Measure-Object -Property Length -Sum).Sum / 1GB

You should see a few GB now. On subsequent image pulls, this number grows.

Finally, verify that Docker isn’t secretly writing to C: anymore:

powershell
1Get-ChildItem "C:\Users\$env:USERNAME\AppData\Local\Docker" -ErrorAction SilentlyContinue

This folder may be empty now or contain only config files, not data.


Troubleshooting

Docker Desktop Won’t Start

If Docker Desktop icon appears in the system tray but immediately crashes or disappears, you likely have a permissions issue or registry mismatch. Open PowerShell as admin and stop any lingering process first:

powershell
1Get-Process -Name "Docker Desktop" -ErrorAction SilentlyContinue | Stop-Process -Force

Then delete the Docker Desktop config cache:

powershell
1Remove-Item "$env:APPDATA\Docker\*" -Recurse -Force -ErrorAction SilentlyContinue

Restart Docker Desktop from the Start Menu. It should reinitialize cleanly.

“Path not found” or “Directory does not exist”

If the installer complains about your path, the directories probably don’t exist or there’s a typo. Verify the path exists first:

powershell
1Test-Path "D:\Containers\docker"

Check that the drive letter is correct:

powershell
1Get-Volume -DriveLetter D

If the directories are missing, recreate them:

powershell
1mkdir "D:\Containers\docker"
2mkdir "D:\Containers\wsl"
3mkdir "D:\Containers\windows-data"

Then re-run the installer.

“Access Denied” or Permission Errors

If the installer fails with a permission error even though you’re running as admin, Windows Defender or antivirus is locking files. Temporarily disable real-time scanning:

powershell
1Set-MpPreference -DisableRealtimeMonitoring $true

Re-run the installer, then re-enable scanning:

powershell
1Set-MpPreference -DisableRealtimeMonitoring $false

Alternatively, add your Docker path to Defender exclusions permanently:

powershell
1Add-MpPreference -ExclusionPath "D:\Containers"

This prevents future scanning slowdowns.

“WSL 2 installation is incomplete” or WSL Errors

If Docker complains about WSL2 not being ready, the WSL2 kernel or distro is missing. Run these commands:

powershell
1wsl --install
2wsl --update

Then restart Windows.

Installation Succeeds but Docker Uses Old C: Drive Path

If docker info still shows C:\ProgramData\Docker, the registry settings weren’t applied or Docker has stale config. Uninstall completely first:

powershell
1wsl --unregister docker-desktop
2wsl --unregister docker-desktop-data

Delete the installation folder:

powershell
1Remove-Item "C:\Program Files\Docker" -Recurse -Force -ErrorAction SilentlyContinue

Then reinstall using the CLI command from the Quick Start section.

“Docker daemon is not running”

If docker commands fail with a daemon not running error, the Docker Desktop service didn’t start. Manually start Docker Desktop from the Start Menu. Wait 10 seconds, then try a docker command:

powershell
1docker ps

If it still fails, check the Docker Desktop logs:

powershell
1Get-Content "$env:APPDATA\Docker\log.txt" -Tail 50

The last 50 lines usually show what’s preventing startup.


Performance Optimization

Once Docker is running from your secondary drive, a few adjustments improve performance.

Real-time scanning on the VHDX file during builds kills performance. Add the WSL directory to Windows Defender exclusions:

powershell
1Add-MpPreference -ExclusionPath "D:\Containers\wsl"

Verify it was added:

powershell
1Get-MpPreference | Select-Object -ExpandProperty ExclusionPath | grep Containers

Open Docker Desktop settings (right-click the icon, then Settings, then Resources) and adjust memory and CPU. Set “Memory” to 50-75% of your available RAM. Set “CPU” to 50% of your available cores. The disk image size auto-allocates to your secondary drive’s available space.

If images pull slowly, your secondary drive itself might be the bottleneck. Test its write speed:

powershell
 1$testFile = "D:\Containers\speed-test.bin"
 2$testSize = 100MB
 3$buffer = new-object byte[] 1MB
 4$file = [io.file]::Create($testFile)
 5$sw = [diagnostics.stopwatch]::StartNew()
 6for ($i = 0; $i -lt ($testSize / 1MB); $i++) {
 7  $file.Write($buffer, 0, $buffer.Length)
 8}
 9$file.Close()
10$sw.Stop()
11$speed = ($testSize / 1MB) / $sw.ElapsedMilliseconds * 1000
12Write-Host "Write speed: $speed MB/s"
13Remove-Item $testFile

If you’re seeing below 50 MB/s, you either need an SSD or you have disk errors. HDDs are too slow for Docker’s VHDX workload.


FAQ

Can I move Docker after installation?

Yes. In Docker Desktop settings (right-click the icon, then Settings, then Resources, then Disk image location), you can change the data path. Docker will re-initialize the VHDX.

What if I only move the WSL data, not the application?

That’s fine. The --installation-dir flag is optional. If you only want to free space, use only --wsl-default-data-root.

Does this work with Docker Compose?

Yes. Docker Compose uses the same Docker daemon, so it inherits the new paths automatically.

Can I symlink the directory instead?

Not recommended. Windows VHDX files don’t play well with symlinks. The CLI flags are the proper way.

How do I migrate containers from C: to D:?

Export containers with docker export, or save images with docker save. Remove the old C: installation and reinstall to D:. When you restart, pull your images again.

Is this reversible?

Yes. Reinstall Docker to C: using the GUI installer or change the path back in Docker Desktop settings.


Why This Matters

Docker pulls large base images (Alpine 370MB, Ubuntu 1.3GB, Node 1.5GB, etc.) and layers them up. A real project easily accumulates 10-20GB. Add multiple projects, build caches, and temporary containers, and your C: drive fills in weeks.

When your C: drive fills, Windows degrades. It can’t write swap files, temp logs, or system caches. The whole machine gets slower. Moving Docker to a secondary drive is one of the highest-impact optimizations you can do as a developer because it’s both simple and immediately tangible.