Increase Docker Data Disk Size to any size with current version of Docker Desktop

Hi folks,

after I read the day potential solutions that were all outdated, i found a solution, after option is gone to set disk size of docker data.vhdx under resources. I moved my vhdx to another location because my disk runs out of space, but ended up that my 250 gb was not enough. Problem: You can enhance the disk external virtually, but docker do not resize the disk accordingly to the new virtual disk size. To increase your docker data.vhdx virtually, run the following command line in your folder with an as admin started powershell, where your vhdx is located:

Resize-VHD -Path docker_data.vhdx -SizeBytes XXXGB

Now enter your wsl:

wsl

next:

lsblk

search in the output the !VIRTUALL increased size! of the disk, mine for instance:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 689.3M 1 loop /mnt/wsl/docker-desktop/cli-tools
loop1 7:1 0 693.6M 1 loop
sda 8:0 0 388.6M 1 disk
sdb 8:16 0 186M 1 disk
sdc 8:32 0 12G 0 disk [SWAP]
sdd 8:48 0 256G 0 disk /mnt/wslg/distro
/
sde 8:64 0 142.4M 0 disk /mnt/wsl/docker-desktop/docker-desktop-user-distro
sdf 8:80 0 XXXG 0 disk <== for me, this was the entry

now:

sudo resize2fs /dev/your-disk

for me, it was: sudo resize2fs /dev/sdf

The output should take some time and will say that the disk on /dev/sdf is now xxx blocks long.

After:

exit

wsl –shutdown

Restart your Docker Desktop, now everything should be now increased not only virtually, Docker should be able to recognize the new size correctly.

Hope this will help someone. Even our GPTs do not know an answer to this question.

1 Like

Is it safe to assume that the vhdx files was initially created with a rather old WSL version?

WSL 2 automatically resizes these VHD files to meet storage needs. By default each VHD file used by WSL 2 is initially allocated a 1TB maximum amount of disk space (prior to WSL release 0.58.0 this default was set to a 512GB max and 256GB max prior to that).

Source: How to manage WSL disk space | Microsoft Learn

Well, this can be true. I can remember that I have updated the WSL to v2, but dunno idk if the docker_data.vhdx was created prior. However, the docker_data.vhdx is an extra disk that is unequal the disk that runs the WSL. I found so many wrong answers, about this topic and non was resolved. My tutorial is still the first, which found a solution to enlarge the vhdx, also above 1 TB. :wink:

Edit:// Idk if new docker installations without a history will create a docker_data.vhdx with the same specs as the WSL2 disk, which is initialized by default with 1 TB.

Thank you for sharing the solution!

Can you share which Windows version you used? I remember some solutions worked for pro and enterprise, but didn’t work on home.

Docker Desktop stopped creating a docker-desktop-data distribution a long time ago, now the docker_data.vhdx is attached to the docker-desktop distro. It has 1TB size:

PS C:\Users\me> wsl -d docker-desktop --system lsblk
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0
       7:0    0 735.1M  1 loop /mnt/wsl/docker-desktop/cli-tools
loop1
       7:1    0 695.8M  1 loop
sda    8:0    0 388.6M  1 disk
sdb    8:16   0   186M  1 disk
sdc    8:32   0     4G  0 disk [SWAP]
sdd    8:48   0 143.9M  0 disk /mnt/wsl/docker-desktop/docker-desktop-user-distro
                               /mnt/wslg/distro
sde    8:64   0     1T  0 disk
sdf    8:80   0     1T  0 disk /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-22.04/a20bd758eff2d4e7bb7e8a12969b185d22ad5d821ee2de286f80550711f45279
                               /mnt/wsl/docker-desktop-bind-mounts/Ubuntu-22.04/8d6522a09792729dfb8493d49afb1e401fc71ff9
                               007c103ca6abd2ff853573a3

Amazing, thanks for sharing your lsblk. Well, in my WSL system the disk is not mounted even if I checked the integration badge under settings. I do not know why. If this happens also to others, its possible to only mount the disk docker_data.vhdx:

wsl --mount docker_data.vhdx --vhd --bare

after that you can start with the lsblk and follow the tutorial.

If you mounted the docker_data.vhdx this way. You must exit und unmount the disk again, after a WSL restart everything is normal again:

exit

wsl --unmount

wsl –shutdown

I run currently Win11 Pro. This solution use only tools available to all windows versions. I also did an upgrade from Win10 to Win11. So the problem, which arouse could be a niche problem and for most applications 1 TB is quite enough. For me, due historic files in docker_data.vhdx it was not an option to delete and let docker recreate it. I found many questions on the net regarding the upscaling of docker_data.vhdx and github issues, with hundreds of comments, that were closed after a year with no solution to the problem. Therefore, I guess this could be helpful also to others.

1 Like