I started using docker images and suddenly i realized lack of space. It took me a while to know that space is being consumed by docker images. So I deleted all the running containers and unnecessary images only to realize that the result of df -h
is still the same. I could see ~/.docker/machine/machines/default/disk.vmdk
still occupying 25GB of space (no change). How can I reclaim the freed space occupied by virtual box image. I am using Mac Yosemite and docker tool (not boot2docker
)
To clean this up, you can use the docker container prune command. By default, you are prompted to continue. To bypass the prompt, use the -f or --force flag. Other filtering expressions are available.
Go to the Applications folder in Finder and find and remove the Docker app to Trash. Now you need to find and remove all application support files of Docker. They are usually stored in the Library folder. As the system Library folder keeps important data, by default, it is hidden from users.
You have to remove the machine. Use
docker-machine rm default
(default
is the name of the default docker-machine)
Beware that you will delete all the images in this way.
There might be ways to compact disk image size (look at this question), but I don't think it worth the hassle. Instead recreate it with a smaller disk size.
Just to be clear, removing the containers and images only save space inside the VM. You can anyway in the future run into trouble because old unused images and container volumes might fill your VM disk. There are actions to be taken to keep it under control, the first of all is always removing containers with the -v
flag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With