Docker is excellent for running services, but over time it can quietly consume a surprising amount of disk space. Images, containers, volumes, build caches, and old layers can accumulate. Tools like Docker dashboards may show the basics, but they do not always reveal everything Docker is storing behind the scenes. This guide explains how to find where Docker uses storage, what is safe to remove, and what you should be careful with.

Where Does Docker Store Its Data?

By default, Docker stores everything under:
/var/lib/docker
However, some homelab users (like myself) move Docker's storage location to another disk because containers and volumes can grow quickly. To find your actual Docker storage location:
docker info | grep "Docker Root Dir"
Example output:
Docker Root Dir: /mnt/DockerStorage/docker
This directory contains the real Docker data.

First: Check Docker's Own Usage Report

Docker has a built-in storage overview:
docker system df
Example:

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          34        32        38.52GB   12.46GB (32%)
Containers      36        35        510MB     20.48kB (0%)
Local Volumes   17        16        14.77GB   2.595GB (17%)
Build Cache     8         0         152.5MB   6.832MB
This immediately shows where storage is going. The important columns are:
  • ACTIVE - currently used by running containers
  • RECLAIMABLE - storage Docker believes can be removed

Checking the Actual Filesystem Usage

Docker's own report is useful, but sometimes you need to see the real directories:
sudo du -h /var/lib/docker --max-depth=1 | sort -h
If you use a custom Docker root /path/to/docker/root = output from docker info | grep "Docker Root Dir":
sudo du -h /path/to/docker/root --max-depth=1 | sort -h
My example output:

sudo du -h /mnt/DockerStorage/docker --max-depth=1 | sort -h
4.0K    /mnt/DockerStorage/docker/runtimes
4.0K    /mnt/DockerStorage/docker/swarm
8.0K    /mnt/DockerStorage/docker/tmp
12K     /mnt/DockerStorage/docker/plugins
80K     /mnt/DockerStorage/docker/image
328K    /mnt/DockerStorage/docker/network
15M     /mnt/DockerStorage/docker/buildkit
897M    /mnt/DockerStorage/docker/containers
16G     /mnt/DockerStorage/docker/volumes
21G     /mnt/DockerStorage/docker/rootfs
38G     /mnt/DockerStorage/docker
    
Common directories:
  • rootfs / overlay2 - image layers
  • volumes - persistent application data
  • containers - container metadata and logs
  • buildkit - build cache

Cleaning Build Cache

Build cache is one of the easiest places to reclaim space.
docker system df
If you see unused build cache:
docker builder prune -a
This removes unused build layers. It does not remove running containers or their data.

Removing Unused Images

Images are often the next largest category.
docker images
Remove only dangling images:
docker image prune
Remove all images not currently used by containers:
docker image prune -a
This is generally safe. Docker will simply download the image again if you later recreate a container that needs it.

Cleaning Stopped Containers

Old containers can remain after testing services. However, I personally, do not clean stopped containers, as I will have projects I work on, on/off, which would also be removed here as I do stop them while not using them. So I just leave them there, as they are not taking up much space anyway. Find them by using this command:
docker ps -a
Remove stopped containers:
docker container prune
Running containers are not affected.

Be Careful With Volumes

Volumes contain actual application data, so be careful when removing them. Common uses for volumes include:
  • Databases
  • Media metadata
  • Configuration files
  • Game server saves
Check unused volumes:
docker volume ls -f dangling=true
Only remove volumes you are certain you no longer need. A command like:
docker volume prune
can permanently delete application data.

Docker Logs

A common hidden problem is container logs. Check:
sudo du -h /path/to/docker/containers --max-depth=2 | sort -h
Large JSON log files can be cleared without stopping containers:
sudo find /var/lib/docker/containers/ \
-name "*-json.log" \
-exec truncate -s 0 {} \;
This only removes logs, not container data.

A Safe Homelab Cleanup Routine

For a typical homelab server:

docker system df

docker builder prune -a

docker image prune -a

docker container prune

docker system df
Avoid blindly removing volumes unless you know exactly what they contain.

Final Thoughts

Docker storage problems are usually not caused by one huge file. They are often the result of many small leftovers:
  • Old image versions
  • Unused build layers
  • Stopped containers
  • Large container logs
The safest approach is always: Inspect first. Remove second. Docker already provides the tools needed to understand its storage. You just need to know where to look.

Final, Final Thought

Personally, I use Arcane Dashboard, which I find to be a great tool for visualizing Docker containers, images, security etc. It helps me easily do the above commands through UI and also gives me a better overview of my Docker environment.