Increase Disk Space on Docker Toolbox
Asked Answered
H

4

38

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?

Hatshepsut answered 1/10, 2016 at 21:31 Comment(0)
H
63

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
Hatshepsut answered 1/10, 2016 at 23:59 Comment(3)
How can i increase the memory of docker-machine ?Validity
Proceed with caution, this method erases all the data in volumesBenzene
units of disk-size are MB, so this will create 100 GB image, FYICahan
T
15

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
Tewell answered 3/10, 2016 at 8:43 Comment(3)
This only increases "physical" space, not partition size as seen by os. Besides, for default virtualbox, the default disk is not .vdi but .vmdk which is not expandable.Matchless
He asked for increasing disk, not partition. so answer is valid, while ".vdi" also implies it just works with .vdi, and how I remember, virtualbox default type is indeed vdi, not vmdk.Poach
The problem I had with this was dockers linux fdisking in cylinders instead of sectors. fdisk -u /dev/sda1 solves this as per man pages linux.die.net/man/8/fdisk if you wish to convert .vmdk to .vdi just use vboxmanage clonehd --format VDI disk.vmdk disk.vdi In the end I wound up just removing the partition and starting over. Bash history allows me to re-run the same commands as on the small 10-20GB docker toolbox ships withSuch
Z
11

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.

Zhukov answered 18/12, 2019 at 11:5 Comment(1)
You don't need to create a second VM. You can just change CD in the existing one from boot2docker to gparted, resize the partition and change it back again.Engstrom
U
6

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

Ustulation answered 30/11, 2017 at 4:31 Comment(2)
Especially useful if you have an existing vm and the virtual disk can not be resized!Repertory
"docker system prune -af" for short (-af -- Remove all unused images not just dangling ones, do not prompt for confirmation)Loppy

© 2022 - 2024 — McMap. All rights reserved.