TECHNIVO.
Technology

How to Move Docker Containers to Another Drive in Windows 11 Without Reinstalling

Running out of C drive space because of Docker? Here is a practical, step-by-step guide to move your Docker containers and WSL 2 virtual disk to a secondary drive safely.

By TechnivoPublished 5 min read (estimated)
In this article
  1. Understanding How Docker Stores Data on Windows 11
  2. Prerequisites and Safety Precautions
  3. Step-by-Step: How to Move Docker Containers and WSL 2 VHDX
  4. Step 1: Verify Your WSL Distributions
  5. Step 2: Shut Down WSL Completely
  6. Step 3: Create Your Target Directory
  7. Step 4: Export the Docker Data Distribution
  8. Step 5: Unregister the Existing Distributions
  9. Step 6: Import the Distributions to the New Drive
  10. Step 7: Clean Up Temporary Files
  11. Verifying Your New Setup
  12. Frequently Asked Questions
  13. Will I lose my running containers or configuration data?
  14. Can I move Docker data to an external USB or network drive?
  15. What should I do if Docker fails to start after the migration?

Docker Desktop is a vital tool for developers and system administrators running containerized workflows on Windows 11. However, it has one major drawback: high storage consumption. By default, Docker Desktop stores all images, volumes, and containers inside a massive virtual disk file on the primary C drive. As you pull more images and spin up databases, that virtual disk expands rapidly, frequently triggering low-disk-space warnings.

Reinstalling Docker Desktop and re-downloading every image wastes valuable time. Fortunately, you can move docker containers to another drive windows 11 without losing work or breaking your setup. Because modern versions of Docker Desktop rely on the Windows Subsystem for Linux (WSL 2), relocating your data simply requires exporting your existing WSL distribution, unregistering it from the default location, and importing it onto a secondary drive.

This guide walks through the exact process to change your data location safely, free up your primary drive, and keep your containers running smoothly.

Understanding How Docker Stores Data on Windows 11

Before using the terminal, it helps to understand what you are moving. When running Docker Desktop on Windows 11, it uses a lightweight WSL 2 utility distribution named docker-desktop alongside the main engine distribution named docker-desktop-data. The latter is where all persistent volumes, container layers, and images live, compiled inside a single file named ext4.vhdx.

By default, Windows stores these files deep within your user profile directory:

C:\Users\YourUsername\AppData\Local\Docker\wsl\

Because the C drive is frequently a faster but smaller solid-state drive (SSD)—while secondary storage offers larger capacity—relocating this ext4.vhdx file is the most effective way to address storage constraints permanently.

Prerequisites and Safety Precautions

Before running command-line operations that modify system virtual disks, take a few basic precautions:

  • Back up critical volumes: If you have vital database volumes or configuration files inside your containers, export or back them up externally. While the migration process is reliable, unexpected power outages or syntax errors can corrupt virtual disks.
  • Shut down Docker Desktop: Ensure Docker is completely closed. Right-click the Docker icon in your system tray and select Quit Docker Desktop.
  • Check available space: Ensure your target secondary drive has enough free space to accommodate the current size of your Docker virtual disks, plus room for future growth.

Step-by-Step: How to Move Docker Containers and WSL 2 VHDX

Follow these steps carefully in Windows Terminal or PowerShell to execute the migration.

Step 1: Verify Your WSL Distributions

Open Windows Terminal or PowerShell with standard user privileges. Run the following command to list your active WSL distributions:

wsl --list -v

You should see an output similar to this:

  NAME                  STATE           VERSION
* docker-desktop        Running         2
  docker-desktop-data   Running         2

If the state shows as Running, shut them down to prevent file locking issues during export.

Step 2: Shut Down WSL Completely

Force WSL to stop all running instances by executing:

wsl --shutdown

Run wsl --list -v again to verify that all distributions display a Stopped state.

Step 3: Create Your Target Directory

Decide where you want to store your new Docker data on your secondary drive (for example, D:\DockerData). Create this folder via PowerShell:

mkdir D:\DockerData

Step 4: Export the Docker Data Distribution

To relocate your virtual disks, you must first export the running state and files of docker-desktop-data into a tarball archive. Depending on how large your current ext4.vhdx file is, this step may take several minutes.

wsl --export docker-desktop-data D:\DockerData\docker-desktop-data.tar

Once the export completes, do the same for the base engine distribution:

wsl --export docker-desktop D:\DockerData\docker-desktop.tar

Step 5: Unregister the Existing Distributions

Now that your data is archived in the tar files, unregister (delete) the old distributions from your C drive to free up the space previously occupied by the old virtual disks.

wsl --unregister docker-desktop-data
wsl --unregister docker-desktop

Note: Unregistering removes the old virtual disk files from their default AppData location, but leaves your newly created .tar backup files untouched on your D drive.

Step 6: Import the Distributions to the New Drive

Next, import the tar archives back into WSL, instructing it to place the new virtual disks (ext4.vhdx) inside your designated secondary folder.

Import the base engine distribution:

wsl --import docker-desktop D:\DockerData\docker-desktop D:\DockerData\docker-desktop.tar --version 2

Import the data distribution:

wsl --import docker-desktop-data D:\DockerData\docker-desktop-data D:\DockerData\docker-desktop-data.tar --version 2

Step 7: Clean Up Temporary Files

Once the import finishes successfully, delete the large .tar files created in Step 4 to reclaim temporary disk space:

Remove-Item D:\DockerData\*.tar

Verifying Your New Setup

With the migration complete, launch Docker Desktop from your Windows Start menu. The initial startup may take slightly longer than usual as WSL initializes the newly placed virtual disks.

Once Docker Desktop reaches the running state, open your terminal and run:

docker ps -a
docker images

You will see that all previous containers, volumes, and images remain completely intact. You can also navigate to D:\DockerData in File Explorer to confirm that new ext4.vhdx files have been successfully generated.

Frequently Asked Questions

Will I lose my running containers or configuration data?

No. By exporting the docker-desktop-data distribution into a tar archive and importing it back into WSL 2, all container layers, volumes, and persistent data are preserved.

Can I move Docker data to an external USB or network drive?

While technically possible, it is strongly discouraged. WSL 2 requires low-latency, stable file system performance. Moving your Docker virtual disk to an external USB drive or a network share will result in severe performance bottlenecks, database timeouts, and potential file corruption.

What should I do if Docker fails to start after the migration?

If Docker Desktop fails to launch, first ensure you ran wsl --shutdown before performing the export and import steps. If issues persist, verify that your user account has full read and write permissions on the target folder on your secondary drive.

Related articles

Leave a Reply

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