Skip to main content

How Much Disk Space Docker Uses and How to Reclaim It

Cloud & DevOps · 13.10.2026 · 5 min read
Illustration for “How Much Disk Space Docker Uses and How to Reclaim It”

Disk space on a Docker server runs out faster than seems logical: containers are stopped, images appear unused, and yet there is still not enough room. The problem is not Docker itself but the fact that it does not delete anything on its own by default — old images, stopped containers, and unused volumes pile up until an administrator steps in manually. This article looks at where the space goes and how to reclaim it without damaging services that are still running.

What Docker's disk usage is actually made of

Docker stores data in several separate categories, and each one grows for its own reason. Images take up space in layers: every step in a Dockerfile adds a new layer, and even outdated versions of an image stay on disk until explicitly removed. Containers, including stopped ones, keep the layer written on top of the image along with logs. Volumes hold application data and are not removed together with a container by default — that is intentional, so a database is not lost when a container is recreated. The build cache accumulates with every image build and can take up a significant share of the disk regardless of how many images are actually in use.

How to see exactly what is taking up space

Before deleting anything, it helps to see the real picture for each category of Docker data:

docker system df
docker system df -v

The first command shows a summary of images, containers, volumes, and the build cache. The second adds a detailed list for every object, including whether it is currently used by a running container or is simply taking up space unused. If the server is already set up following the article "Setting up Docker on a VDS", these commands are available right after installation with no extra steps.

Comparing ways to clean Docker data off the disk

CommandWhat it removesRisk to running services
docker container pruneStopped containersLow — does not touch running containers
docker image pruneUntagged images not linked to any containerLow when used without the -a flag
docker image prune -aAll images not used by any containerMedium — may remove images kept in reserve
docker system prune --volumesContainers, images, build cache, and unused volumesHigh — volumes may hold application data

If part of the services is described through docker-compose, it helps to check the configuration file after cleanup — the rebuild sequence is described in the article "Setting up docker-compose".

Why space disappears again after cleanup

Some time after pruning, the disk starts filling up again, and the cause is usually one of three:

  • Container logs grow without limit if the Docker configuration does not set a cap on log file size
  • CI/CD builds new images on the same server, adding layers faster than old ones become outdated
  • Volumes holding database or queue data grow along with the load on a service and are not "junk" that can simply be deleted

Catching the moment when space starts running low again is easier with continuous disk usage monitoring — how to set it up is described in the article "VDS monitoring".

What to do: a safe order for cleaning the disk

To avoid deleting a running application's data along with the junk, it helps to proceed step by step rather than with one broad command.

  1. Check the summary with docker system df and determine which category of data takes up the most space
  2. Remove stopped containers with docker container prune if they are no longer needed for debugging
  3. Remove unused images without the -a flag the first time, to avoid touching images that might still be needed
  4. Limit container log size in the Docker configuration so space does not run out again the same way
  5. Set up a regular check of free disk space rather than a one-off manual cleanup

Frequently asked questions

Why does Docker take up so much disk space?

The main reason is the layered structure of images and the lack of automatic cleanup by default: every build adds data, and old images, containers, and the cache stay on disk until explicitly removed with prune commands.

How much disk space does Docker typically use?

The exact amount depends on the number of images, how often builds run, and the volume sizes of a specific project, so there is no general figure — it is more reliable to check the real picture once with the docker system df command on the actual server.

Is it safe to run docker system prune on a production server?

The command itself without the --volumes flag does not touch data in volumes and does not stop running containers, so in its basic form it is reasonably safe. The --volumes flag should only be added after checking which volumes are genuinely unused.

Was this article helpful?
← Back to Knowledge Base Ask Support