Checking space

When working with multiple projects, you could find that your Virtual Machine's disk space starts to run out. 

To check how much space is left on your machine:

# SSH into your docker VM
you@your-machine$ docker-machine ssh default

# Inside the docker VM, run df to get an overview of the disk space
docker@docker-machine$ df -h

Filesystem Size Used Available Use% Mounted on
tmpfs 1.8G 115.3M 1.6G 6% /
tmpfs 1000.9M 664.0K 1000.3M 0% /dev/shm
/dev/sda1 47.0G 13.8G 30.8G 31% /mnt/sda1  # <--- note this line
cgroup 1000.9M 0 1000.9M 0% /sys/fs/cgroup
none 464.8G 425.2G 39.6G 91% /Users
/dev/sda1 47.0G 13.8G 30.8G 31% /mnt/sda1/var/lib/docker/aufs
none 47.0G 13.8G 30.8G 31% /mnt/sda1/var/lib/docker/aufs/mnt/a015af55d4a9541e135e1a98382802826d44288d83fa16d4a879ef965c71890b

In this example, /dev/sda1 is our disk of interest and shows that 30.8GB is free while 13.8GB is used. To quit the prompt inside the docker VM, simple type 'exit' and hit enter.

Deleting Docker images

If you're running out of space in the Docker machine, you will need to delete some unwanted Docker images. It's generally pretty safe to delete a Docker image - it will simply be recreated the next time you run "divio project setup".

However, you must make sure that you have pushed any database changes to Divio Cloud, otherwise these will be lost.

Delete a particular image

# list all Docker images
docker images
hello-world   latest c54a2cc56cbb 3 months ago  1.848 kB

# delete an image
docker rmi hello-world

# in case you need to force-delete it
docker rmi -f hello-world

# remove all containers
docker rm $(docker ps -a -q)
# remove all images
docker images | awk '{if(NR>1) print $3}' | xargs docker rmi -f 

Delete all images

You can also remove all images. Be warned that these commands will also remove non-Divio Cloud containers and images.

# remove all containers
docker rm $(docker ps -a -q)
# remove all images
docker images | awk '{if(NR>1) print $3}' | xargs docker rmi -f 

Creating a virtual machine with more disk space

If you regularly find yourself running short of disk space in your virtual machine, you can create one that has more to begin with.

WARNING: This will delete all existing containers or images used by the docker VM. Please be aware that you might lose data from non-Divio Cloud related containers as well!

You can set disk size using the "--virtualbox-disk-size" flag.

To delete your old VM and create a new one from scratch with 100GB, you'd run:

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

For more information please see Docker documentation.

Did this answer your question?