3

I have a Ubuntu container that has a volume where my postgresql database is stored. My database has run out of space as it has failed over, and I can see disk usage is at 100% when I query disk stats on the Ubuntu container:

root@b2b1bc6c247c:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay          59G   58G     0 100% /
tmpfs            64M     0   64M   0% /dev
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
shm              64M     0   64M   0% /dev/shm
/dev/sda1        59G   58G     0 100% /etc/hosts
tmpfs           3.9G     0  3.9G   0% /proc/acpi
tmpfs           3.9G     0  3.9G   0% /sys/firmware

I have increased the Disk image size to 160GB in the Docker for Windows settings and applied the changes, however when I restart the container the new disk space has not been allocated.

I'm quite confused as to whether this is an issue with the container that is reporting 100% usage or the volume where the data is actually being stored.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
algorhythm
  • 3,304
  • 6
  • 36
  • 56
  • windows with docker desktop now has purge data option -> https://stackoverflow.com/a/73137144/6563567 – ns15 Jul 27 '22 at 11:58

1 Answers1

3

I ran into this problem a while back as well. I'm not sure if the Stable version has the fix added yet, but I believe they fixed it in the Edge version.

Either way, you can do it through the Hyper-V Manager. You click the Edit Disk item and you can then expand the disk size there. Make sure you completely shutdown and exit Docker first.

enter image description here

Also, after I did mine I optimized it, like this:

To Optimize/Shrink the VM (in Powershell):

  1. Mount-VHD -Path "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\DockerDesktop.vhdx" -ReadOnly
  2. Optimize-VHD -Path "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\DockerDesktop.vhdx" -Mode Full
  3. Dismount-VHD -Path "C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\DockerDesktop.vhdx
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
  • Thanks so much! This was driving me crazy. I couldn't find any other reference of this occuring. Well done finding the solution. – algorhythm May 12 '20 at 15:54
  • @algorhythm Happy to help. There was also a problem that I discovered while facing the problem, where after finally doing the steps above, the DD UI wasn't reflecting the new size changes (that slider in the Resources section). I was actually the one who reported the bug that they confirmed and released a fix for, in the Edge version 2.2.3.0, lol. https://github.com/docker/for-win/issues/5881 – J. Scott Elblein May 13 '20 at 12:24