Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

6 November 2026 · One command a day

How do I free up disk space used by Docker on Linux?

docker system prune removes the Docker leftovers that build up on a server. These are stopped containers, unused networks, dangling images and old build cache. Use it when your disk is filling up and Docker turns out to be the cause.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

sudo docker system prune

sudo is needed because the Docker daemon runs as root, unless your user is in the docker group. docker system is the group of commands that act on Docker as a whole rather than on one container. prune deletes anything nothing is using, and it asks you to confirm first. You can add three options. -a also removes every image that no container uses, not just dangling ones, and clears all build cache. -f skips the confirmation prompt. --volumes also removes anonymous volumes that no container uses.

What you will see

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - unused build cache

Are you sure you want to continue? [y/N] y
Deleted Containers:
4f2c1a9e7b3d8c6a5e1f0b2d9a7c3e4f5b6a7d8e9f0a1b2c3d4e5f6a7b8c9d0e

Deleted Networks:
appname_default

Deleted Images:
deleted: sha256:9b1e5c7a3d2f4e6b8a0c1d3e5f7a9b2c4d6e8f0a1b3c5d7e9f2a4b6c8d0e1f3a

Deleted build cache objects:
k3x9q2m7v1p8w4z6r5t0y3u2i

Total reclaimed space: 2.314GB

The warning lists what will go. Nothing happens until you type y. Each section then lists the IDs or names that were deleted. An empty section means there was nothing of that kind to remove. The last line is the one you care about: how much disk you got back.

When to use it

Watch out for

The word stopped matters. If you stopped a container on purpose, for example with docker compose stop, prune deletes it along with anything written inside it that is not in a volume. With -a it also deletes that stack's images, so the next start has to download them again. Before you prune, check what you have with sudo docker ps -a, as covered in how to see which Docker containers are running.

Questions people ask

Does docker system prune delete my volumes?

No. By default volumes are kept. --volumes removes only anonymous volumes that no container uses. Named volumes, where databases usually live, are not touched.

How do I see how much space Docker is using before I prune?

Run sudo docker system df. It shows the space used by images, containers, local volumes and build cache, and how much of each could be reclaimed.

Cleaning up Docker's disk usage like this is something you can only do on a server you control. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I check disk space on a Linux server? · How do I update a Docker Compose container to the latest image? · How do I find what is using disk space on Linux? · All daily notes