Site's logo

KL, MY

7:30:00 AM

Network cables as supply for work of system by Brett Sayles on Pexels

Move Docker Desktop Data to Another Fixed Drive on Windows

Learn how to move Docker Desktop data to another drive on Windows using a custom fixed-size VHDX disk with Hyper-V.

May 9, 2025

4 min read

Docker Desktop on Windows via WSL2 is a great way to run Docker containers. However, the default installation location can fill up your C: drive quickly, especially when using large images or volumes. Fortunately, you can move Docker Desktop data to another drive using a custom fixed-size VHDX disk with Hyper-V.

Prerequisites

  • Windows WSL2 installed and configured
  • Docker Desktop installed
  • Hyper-V enabled (How to Enable Hyper-V on Windows)
  • A backup of your docker data (volumes, images, etc..) if you have any important data in Docker Desktop. This process involves moving and replacing files, so it’s always a good idea to have a backup in case something goes wrong.

The Problem

Docker Desktop uses a virtual hard disk (VHDX) to store its data. By default, this VHDX is created on the C: drive and is dynamically sized, meaning it can grow as needed without first allocating all the space.

This can lead to issues as the VHDX file can grow significantly, consuming all available space on the C: drive. To avoid this, you can create a custom fixed-size VHDX on another drive and point Docker Desktop to use it instead.

The VHDX file does not shrink automatically when you delete data. You have to either use the Optimize-VHD command or the diskpart command to shrink it manually. In some cases, you may be able to shrink it down to a smaller size, but often it will not shrink down to the size you expected.

The Solution

Create a custom fixed-size VHDX on another drive and point Docker Desktop to use it instead of the default VHDX. This will allow you to control the size of the VHDX file and prevent it from consuming all available space on your C: drive.

Steps to Move Docker Desktop Data

  1. Open Hyper-V Manager:

    • Press Windows + S, type “Hyper-V Manager”, and open the application.
    Hyper-V Manager interface
    Hyper-V Manager interface
  2. Create a New Fixed-Size Virtual Hard Disk:

    • In the Hyper-V Manager, click on New in the right sidebar and select Hard Disk.
    Setup wizard starting page for creating a new hard disk
    Setup wizard starting page for creating a new hard disk
    • Choose VHDX as the format

    Select VHDX format for the new hard disk
    Select VHDX format for the new hard disk
    - Choose Fixed size as the type of disk.

    Select fixed size for the new hard disk
    Select fixed size for the new hard disk
    - Specify the name of the new VHDX file as docker_data.vhdx and choose the location on the new drive where you want to store it. This VHDX file will later be moved to replace the default Docker Desktop VHDX.”

    Specify the location for the new hard disk
    Specify the location for the new hard disk
    - Set the desired size for the VHDX file (e.g., 100 GB). Remember, this allocated space will be reserved on your drive immediately. While this size can often be increased later if needed, it cannot be easily decreased.

    Configure the size of the new hard disk
    Configure the size of the new hard disk
    - Click Finish to create the new VHDX file.

    Summary of the new hard disk creation
    Summary of the new hard disk creation

    The newly created VHDX file will immediately consume the specified size (e.g., 100 GB) on the new drive. This is different from the default Docker Desktop VHDX, which is dynamically sized and can grow as needed.

  3. Move the Docker Desktop disk image location to your desired drive:

    • Open Docker Desktop.
    • Click on the Settings icon (gear icon) in the top right corner.
    • Go to the Resources tab.

    Docker Desktop resources settings
    Docker Desktop resources settings
    - Click Browse and select the location of where you wanted docker to store the data. This will create a new directory - DockerDesktopWSL with subdirectory disk and main. - Click Apply & Restart. Docker Desktop will apply the changes, restart, and initialize the new storage location by creating its own VHDX file in the designated disk folder. - After Docker Desktop has fully restarted using the new location, quit Docker Desktop. Ensure the Docker icon is no longer in the system tray to confirm it’s not running in the background. - Delete the DockerDesktopWSL/disk/docker_data.vhdx file and move the docker_data.vhdx file you created in step 2 to the DockerDesktopWSL/disk directory. - Start Docker Desktop again.

You have now successfully moved Docker Desktop data to another drive using a custom fixed-size VHDX disk with Hyper-V. This will help you manage disk space more effectively and prevent the C: drive from filling up quickly.