Skip to main content

How to Increase Docker Disk Size in Windows (WSL 2 Backend)

If you are using Docker with WSL 2 backend and cannot increase the disk size from the Docker Desktop settings, follow these steps:

Step 1: Check Current Disk Size

  1. Open PowerShell and run:

    wsl --list --verbose

    This will show the installed WSL distributions. Identify the distribution where Docker is installed (usually docker-desktop-data).

  2. Shut down WSL:

    wsl --shutdown

Step 2: Locate the WSL Disk Image

The WSL disk image is stored as a .vhdx file. By default, it is located in:

C:\Users\YourUsername\AppData\Local\Docker\wsl\data\ext4.vhdx

(Replace YourUsername with your actual Windows username.)


Step 3: Resize the WSL Disk

  1. Open PowerShell as Administrator and run:

    cd "C:\Users\YourUsername\AppData\Local\Docker\wsl\data\"
    wsl --shutdown
  2. Run diskpart:

    diskpart
  3. Inside diskpart, execute:

    select vdisk file="C:\Users\YourUsername\AppData\Local\Docker\wsl\data\ext4.vhdx"
    expand vdisk maximum=512000
    exit

    (Change 512000 to the required size in MB, e.g., 500GB = 512000MB.)


Step 4: Resize the Filesystem Inside WSL

  1. Start WSL again:

    wsl
  2. Resize the file system:

    sudo resize2fs /dev/sdX

    (Replace /dev/sdX with the correct partition name, which you can find using df -h inside WSL.)


Step 5: Restart Docker

  • Restart Docker Desktop and check if the disk size has increased.

After following these steps, you should be able to allocate more space for Docker volumes.


Post Tags: