Vincent Ombogo
AboutServicesProjectsBlogTestimonialsContact
Background grid pattern

Let's work together

Interested in collaborating? Reach out and let's build something great.

Copyright © 2026 Vincent Ombogo

Back to Blog
How to Clean Your VPS Server Safely (Ubuntu + Docker + Coolify)
VPSUbuntuDockerCoolifyLinuxDevOpsServer Management

How to Clean Your VPS Server Safely (Ubuntu + Docker + Coolify)

Learn how to safely clean your Ubuntu VPS, free disk space, remove unused Docker resources, and keep your server running smoothly without breaking your applications.

Vincent OmbogoAugust 7, 20267 min read

How to Clean Your VPS Server (Step-by-Step Guide for Beginners)

If your VPS has started running slowly, deployments are failing, or you're seeing messages like "No space left on device", don't panic. This guide will walk you through cleaning your server safely—even if you've never used Linux before.

We'll explain what each command does, why you're running it, and what to expect after running it.

Who is this guide for?

  • Beginners using Ubuntu VPS
  • Coolify users
  • Docker users
  • Anyone whose VPS is running out of storage

Before You Begin

What is a VPS?

A Virtual Private Server (VPS) is your own computer running in the cloud. It hosts your websites, applications, and databases.

Just like your laptop, your VPS collects temporary files, logs, unused downloads, and old application files over time.

Cleaning these files regularly keeps your server healthy.


Step 1: Connect to Your VPS

You first need to log into your server.

Windows (PowerShell)

Open PowerShell and type:

hljs bash
ssh root@YOUR_SERVER_IP

Example:

hljs bash
ssh root@123.45.67.89

Replace YOUR_SERVER_IP with your VPS IP address.

If this is your first time connecting, you'll see:

Are you sure you want to continue connecting?

Type:

yes

Then press Enter.

Enter your password if requested.

If you're using SSH keys, you'll log in automatically.


Step 2: Check How Much Storage Is Used

Before deleting anything, let's see how full the server is.

Run:

hljs bash
df -h

Example output:

Filesystem Size Used Avail Use% /dev/sda1 40G 37G 2G 95%

What does this mean?

ColumnMeaning
SizeTotal storage
UsedStorage already used
AvailFree storage left
Use%Percentage used

If your server is above 85%, it's a good idea to clean it.


Step 3: Find What's Using the Storage

Run:

hljs bash
du -h --max-depth=1 / 2>/dev/null | sort -hr | head -20

This command lists the biggest folders on your server.

Example:

12G /var 8G /home 4G /usr

Don't delete anything yet.

We're only identifying where the storage is being used.


Step 4: If You Use Docker or Coolify

Most developers using Coolify store applications inside Docker.

Check Docker's storage usage:

hljs bash
docker system df

Example:

Images 12GB Containers 2GB Volumes 8GB Build Cache 6GB

Docker often consumes the most storage on a VPS.


Step 5: Clean Ubuntu Package Cache

Whenever Ubuntu installs software, it saves downloaded installation files.

These files are no longer needed after installation.

Run:

hljs bash
sudo apt clean

Nothing important is deleted.

Only temporary installation files are removed.


Step 6: Remove Old Packages

Sometimes Ubuntu keeps packages that are no longer being used.

Remove them:

hljs bash
sudo apt autoremove -y

This safely removes software that your system no longer needs.


Step 7: Clean Old System Logs

Every application writes logs.

Over months, they can grow into several gigabytes.

Check their size:

hljs bash
journalctl --disk-usage

Example:

Archived and active journals take up 1.8G.

Keep only the last seven days:

hljs bash
sudo journalctl --vacuum-time=7d

Or keep only 200MB:

hljs bash
sudo journalctl --vacuum-size=200M

Either option is perfectly fine.


Step 8: Remove Unused Docker Files

Docker stores:

  • Old containers
  • Old images
  • Build cache
  • Networks

Many of these are no longer needed.

Clean them:

hljs bash
docker system prune

Docker asks:

Continue? [y/N]

Type:

y

Press Enter.

If you don't want the confirmation:

hljs bash
docker system prune -f

Step 9: Remove Old Docker Images

If you've deployed your application many times, Docker keeps old versions.

Delete images that are no longer used:

hljs bash
docker system prune -a -f

This can free several gigabytes.

Your next deployment may take slightly longer because Docker downloads the images again.


Step 10: Clean Docker Build Cache

Every deployment creates build files.

These build files aren't needed forever.

Check cache size:

hljs bash
docker builder du

Then remove it:

hljs bash
docker builder prune -a -f

This is one of the easiest ways to recover storage.


Step 11: Check Docker Volumes (Important)

Volumes store your important data.

Examples:

  • MongoDB
  • PostgreSQL
  • MySQL
  • Redis
  • Uploaded files
  • Coolify data

View them:

hljs bash
docker volume ls

⚠️ Important

Do NOT run:

hljs bash
docker volume prune

unless you are 100% sure the volumes are no longer needed.

Deleting the wrong volume can permanently erase your database.


Step 12: Remove Large Docker Logs

Containers generate logs every second.

Find large logs:

hljs bash
find /var/lib/docker/containers/ -name "*-json.log" -exec du -h {} + | sort -hr | head

If a log file has become very large, clear it:

hljs bash
find /var/lib/docker/containers/ -name "*-json.log" -size +100M -exec truncate -s 0 {} \;

This clears the logs without stopping your applications.


Step 13: Check Coolify Backups

If you use Coolify, backups may occupy a lot of storage.

Check backup size:

hljs bash
du -sh /data/coolify/backups

Delete only backups you no longer need.

Always keep at least one recent backup.


Step 14: Check Your Storage Again

Now see how much storage you've recovered.

Run:

hljs bash
df -h

Compare it with the first result.

You should now have significantly more free space.


Step 15: Make Sure Everything Still Works

Check your running applications.

hljs bash
docker ps

You should see all your containers running.

Then open your website in a browser.

Make sure:

  • Your website loads
  • Login works
  • Database works
  • Images load
  • Applications respond normally

If everything works, your cleanup was successful.


How Often Should You Clean Your VPS?

For most servers:

Server UsageRecommended Cleanup
Personal projectsEvery 2–3 months
Small business websitesMonthly
Production applicationsEvery 2–4 weeks
Frequent deploymentsWeekly

Common Mistakes to Avoid

❌ Deleting Docker volumes without checking them.

❌ Deleting random folders because they're large.

❌ Cleaning logs while debugging an issue.

❌ Removing backups before confirming you have another copy.

❌ Ignoring low disk space warnings.


Quick Cleanup Commands

If you're already comfortable with Linux, these commands perform the most common cleanup tasks:

hljs bash
df -h
docker system df
apt clean
apt autoclean
apt autoremove --dry-run
journalctl --vacuum-time=7d
docker system prune -a
docker builder prune -a
df -h
docker system df

Final Thoughts

Cleaning your VPS doesn't have to be intimidating. By following the steps in this guide, you can safely free up disk space, improve performance, and avoid common storage-related issues without risking your applications or data.

A good habit is to check your server's disk usage once a month and perform a cleanup whenever storage usage exceeds 80%. Regular maintenance keeps deployments smooth, applications responsive, and your VPS ready for future growth.

Whether you're hosting a personal portfolio, a business website, or multiple applications with Docker and Coolify, a little maintenance goes a long way toward keeping your server reliable.

Share this article:

Related Articles

Why Every Small and Medium Business Needs a Professional Website in 2026
BusinessSMEs

Why Every Small and Medium Business Needs a Professional Website in 2026

Discover how a modern website helps small and medium businesses attract more customers, build trust, and increase sales

Aug 5, 20264 min read
How to Turn Your Web App into a Mobile App with Capacitor (Complete Beginner's Guide)
CapacitorMobile App Development

How to Turn Your Web App into a Mobile App with Capacitor (Complete Beginner's Guide)

Learn how to transform your existing web application into a native Android and iOS app using Capacitor. A step-by-step guide for developers using Next.js, React, Vue, Angular, or any modern web framework.

Aug 5, 20269 min read
Getting Started with Next.js 16: What's New and Why You Should Care
Next.jsReact

Getting Started with Next.js 16: What's New and Why You Should Care

Next.js 16 brings groundbreaking features including the Turbopack stable release, React 19 support, and enhanced server actions. Here's everything you need to know.

Jul 20, 20268 min read