How to fix the running out of disk space error in Docker?

Pritam Banerjee picture Pritam Banerjee · Jul 9, 2018 · Viewed 24.7k times · Source

When I am trying to build the docker image I am getting out of disk space error and after investigating I find the following:

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        4G   3.8G     0 100% /

How do I fix this out of space error?

Answer

Nick Spicer picture Nick Spicer · Jul 9, 2018
docker system prune

https://docs.docker.com/engine/reference/commandline/system_prune/

This will clean up all images, containers, networks, volumes not used. We generally try to clean up old images when creating a new one but you could also have this run as a scheduled task on your docker server every day.