I ran into this using very large docker buildx
caches, and I didn't want to prune all of them since the filter argument is currently broken
PS> docker run -it --rm ubuntu:18.04 df -h
Filesystem Size Used Avail Use% Mounted on
overlay 252G 249G 0G 100% /
tmpfs 64M 0 64M 0% /dev
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
shm 64M 0 64M 0% /dev/shm
/dev/sdd 252G 249G 0G 100% /etc/hosts < this is the device we have to expand
Take note of which device is full. This is the disk you must resize later.
Expand virtual disk using diskpart
Under WSL2
and following the instructions from Microsoft on expanding the size of your vdisk, this should allow you to expand the data/isocache mount.
If you're like me and moved your Docker vhdx
from AppData/Packages
and it is not listed in the Docker Desktop GUI, you may be able to find it in the settings:
PS> cat $env:APPDATA\Docker\settings.json | Select-String dataFolder
"dataFolder": "D:\\DockerDesktop",
Find the ext4.vhdx
file under the wsl/data
directory (not the DockerDesktop.vhdx
!) Use diskpart
to expand the disk.
DISKPART> select vdisk file="D:\DockerDesktop\wsl\data\ext4.vhdx"
DiskPart successfully selected the virtual disk file.
DISKPART> detail vdisk
Device type ID: 0 (Unknown)
Vendor ID: {00000000-0000-0000-0000-000000000000} (Unknown)
State: Added
Virtual size: 256 GB
Physical size: 252 GB
Filename: D:\DockerDesktop\wsl\data\ext4.vhdx
Is Child: No
Parent Filename:
Associated disk#: Not found.
To expand to 512 GB, enter the size in MB (512000) and exit diskpart
DISKPART> expand vdisk maximum=512000
DISKPART> exit
Expand in WSL
To allow Docker to use the extra space, launch your WSL2 distribution. You don't need to use docker for this (which is where I personally got a bit confused)
PS> wsl
user@WSL2:/mnt/c/Users/user$ sudo mount -t devtmpfs none /dev
user@WSL2:/mnt/c/Users/user$ mount | grep ext4
/dev/sdb on / type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)
/dev/sdd on /mnt/wsl/docker-desktop-data/isocache type ext4 (rw,relatime,discard,errors=remount-ro,data=ordered)
isocache
is on /dev/sdd
(which matches the full disk from earlier). Run resize2fs
with the new size postfixed with the sizetype
sudo resize2fs /dev/<DEVICE> 512000M
Check that you have more room!
docker run -it --rm ubuntu:18.04 df -h
Filesystem Size Used Avail Use% Mounted on
overlay 492G 249G 220G 54% /
tmpfs 64M 0 64M 0% /dev
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
shm 64M 0 64M 0% /dev/shm
/dev/sdd 492G 249G 220G 54% /etc/hosts