DEV Community

Vuyisile Ndlovu
Vuyisile Ndlovu

Posted on • Originally published at vuyisile.com on

Freeing up space used by docker containers.

When building or working with docker containers, you may get error messages like the one below relating to a lack of space:


failed to copy files: failed to copy directory: Error processing tar file(exit status 1): write /<directory>: no space left on device

Enter fullscreen mode Exit fullscreen mode

The error occurs because Docker objects accumulate over time and can eventually exhaust available storage. To resolve do the following:


docker system df

Enter fullscreen mode Exit fullscreen mode

This will tell you how much space Docker objects are taking up in your machine. Docker includes a prune command that allows you to reclaim space. You can use prune to delete all objects or some images. You can read more about it in the docs.


# Prune everything
docker system prune

# Only prune images
docker image prune

Enter fullscreen mode Exit fullscreen mode

This will hopefully clear up space. If this doesn’t work, you may need to allocate more disk space to docker.

Discussion (0)