Increase Disk Space on Docker Toolbox

老子叫甜甜 提交于 2020-07-31 07:57:11

问题


I'm trying to start some very large Containers on Docker Toolbox (about 18 GB in total). Unfortunately, I always get the error that there is not enough disk space. I have a 1TB HDD and there are more than 200 GB free.

How can I increase the disk space for docker toolbox?


回答1:


OK, I finally found the solution:

Open Docker Quickstart Terminal, remove the virtual docker-machine and add a new one:

 $ docker-machine rm default
 $ docker-machine create -d virtualbox --virtualbox-disk-size "100000" default



回答2:


You can resize without having to delete the VM and recreate it. By default Docker Machine uses VirtualBox, which has the vboxmanage command line tool for working with VMs. You can use the modifymedium command to change disk size:

vboxmanage modifymedium docker-vm.vdi --resize 100000



回答3:


In my case I had a lot of stopped containers, images and volumes - eating up space. Below commands help:

docker container prune

docker volume prune

docker image prune




回答4:


I encountered the same issue. I was not prepared to lose any of my existing images or containers, so neither creating a new disk nor pruning my data were options for me. Here is how you can resize your disk without losing any of your data.

Docker Toolbox creates a VMDK file per default. VirtualBox cannot resize this format. So, before you can resize it, you have to convert it to a VDI file.

Go to your VirtualBox interface and detach the VMDK file from your "default" machine. Afterwards, clone the VMDK file to a VDI file:

VBoxManage clonemedium disk --format VDI "C:\Users\me\.docker\machine\machines\default\disk.vmdk" "C:\Users\me\.docker\machine\machines\default\disk.vdi"

You can now resize the VDI file. The last parameter of the following command specifies the new size in MB:

VBoxManage modifyhd "C:\Users\me\.docker\machine\machines\default\disk.vdi" --resize 30720

Now the disk is resized, but the partition is not. To resize the partition to fit the size of the disk, download GParted and create a new virtual machine. Attach your VDI disk and the GParted Live CD to the new machine. It will boot GParted and you can then use it to resize the partition to use the entire disk. There are a lot of detailed instructions how to do this on the internet, for example here. Once you have done that, shutdown the GParted VM.

Attach the VDI file to your "default" machine. Run docker-machine start and it should boot your Docker machine with the resized virtual disk. If everything is working as intended, you can now delete the old VMDK file or archive it for backup purposes.



来源:https://stackoverflow.com/questions/39811650/increase-disk-space-on-docker-toolbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!