简体   繁体   中英

How to shrink Docker disk image, but keep volumes in Docker for Mac?

When decreasing the size of the Docker disk image, Docker for Mac gives a warning, that it will delete all images, containers and volumes. 在此处输入图像描述

I don't mind losing the images and containers, but is there a way to preserve the volumes? Is there a way to temporarily "copy" the volumes from the Docker disk image to another part of the host file system, shrink the disk image, than copy the volumes back to it?

The volumes are at /mnt/sda1/var/lib/docker and /var/lib/docker/volumes ; you could try ssh'ing into the VM and copying them back and forth. I've never tried it myself though.

Also, I'm not sure about how a mac deals with the docker VM, but on Windows we can manipulate the size of the VM file itself by using the Wizard in the Hyper-V manager. Maybe there's something similar in a Mac? Then you'd be bypassing the Docker UI's way of adjusting the VM size.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM