Filed under Hosting & Infrastructure Docker

Docker cleanup commands to free up disk space on a VPS

Quick Docker commands I use to reclaim disk space on my VPS by removing unused images, containers, and build cache while keeping project volumes intact.

Written by
Farhan Munim
Published
Updated
Reading time
1 min

Docker can quietly consume gigabytes of storage over time. When my VPS starts running low on disk space, I use these two commands…

The first command removes unused Docker build cache:

docker builder prune -a -f 

The second removes unused images, stopped containers, networks, and other Docker resources:

docker system prune -a -f

Importantly, these commands do not remove Docker volumes, so project data and databases remain safe.

To see how much space Docker is using before and after cleanup:

docker system df

I run this cleanup periodically on my VPS to keep storage usage under control.