If you ever had issues with your Docker on WSL having not enough capacity, this guide is for you.
It’s based on this issue on GH and the official MS docs, however there are some errors on the docs, so this guide should fix those:
# On Windows, terminate all WSL instances
wsl --shutdown
# FOn WSL Ubuntu, check which fs is full
df -h
# In my case it was /dev/sdd (the Docker's data)
# ...
# /dev/sdd 251G 226G 13G 95% /mnt/wsl/docker-desktop-data/isocache
# ...
# That volume is mapped to the hyper-v vdisk in Windows
# C:\\Users\\vilso\\AppData\\Local\\Docker\\wsl\\data\\ext4.vhdx
# Note that the distro vdisk is the one at
# C:\\Users\\vilso\\AppData\\Local\\Docker\\wsl\\distro\\ext4.vhdx
# On Windows, run a Powershell as admin and run
diskpart
# While on Diskpart, load the vdisk .vhdx file
select vdisk file="C:\\Users\\vilso\\AppData\\Local\\Docker\\wsl\\data\\ext4.vhdx"
detail vdisk
# You'll see that the physical size reached it's maximum, let's resize it
# (use MB as unit, here I'm resizing from 256 GB to 512 GB)
expand vdisk maximum=512000
exit
# Make WSL aware that it can expand the fs (ignore errors if they happen)
sudo mount -t devtmpfs none /dev
# Find the device name that you want to resize and its size (that we just updated):
sudo lsblock
# ...
# sde 8:64 0 500G 0 disk /mnt/wsl/docker-desktop-data/isocache
# ...
# In my case it's the isocache one, note the `sde` device name and the `500G` size
# Now let's actually resize the device /dev/sde to 500G
sudo apt install resize2fs
sudo resize2fs /dev/sde 500G
# Now you should see the device recognized with the right size
df -h | grep /dev/sde
# /dev/sde 492G 260G 209G 56% /mnt/wsl/docker-desktop-data/isocache