# 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.

Author: Farhan Munim  
Published: 31 May 2026  
Updated: 26 October 2026  
Tags: Docker, VPS  
Source: https://farhan.app/blog/docker-cleanup-commands-to-free-up-disk-space-on-a-vps/

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:

```bash
docker builder prune -a -f 
```

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

```bash
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:

```bash
docker system df
```

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