22/03/2025

Cleaning up Docker cache and free up space

By snorlaxprime

When you are running Docker in raspberry pi, the space are premium, so after several update to my docker image, it is hogging the space until I am running out of storage, which makes the system slow beyond imagination. So here we go.

Step 1. Check how much disk space Docker is using

You can use the following command

docker system df

As you can see above I have 6 images, but 5 that is active and I can reclaim 214.6MB, and I have 5 containers but only 4 that is active.

Step 2. Remove unused image

Now that I know that I have one unused image, I ant to remove it, so use the following command to remove the image that are not associated with any container

docker image prune

As you can see above the old image is pruned and 112.7MB was reclaimed.

Step 3. Removing volumes

We can also remove the volume by using the following command

docker volume prune

In this instance we don’t have any volume that are not associated with containers.

we can check the volume using the following command

docker volume ls

I hope this is useful, as I manage to reclaim quite a bit of disk space. If you need more details explanation on how the docker cache works you can find it in the following location

https://depot.dev/blog/docker-clear-cache