This script can help you save time from downloading/rebuild docker images when you want to use Factory Reset or Resize Disk Image in Docker for Mac which deletes all local images.
If you have Time Machine enabled, You can use this command to free up a significant amount of disk space:
tmutil thinlocalsnapshots / 10000 4
For me, I have around 30 images on my dev machine which takes around 25GB
on-disk space to backup.
The backup size would be much larger than the size given by docker system df
because storage layers are shared between images when it's in docker but not shared in backups.
Once the disk is full, it would trigger OOM which randomly kill your living applications, You would have to do hard reboot to fix it.
./save_images.sh
Will back all docker images with non-none name and tag to directory images-<date>-<random>
./restore_images.sh <images-backup-directory>