Running out of disk space on your home lab can bring your entire Docker setup to a grinding halt. When updates fail and databases lock up, a panicked system prune can spell disaster for your precious data. In this guide, discover how to safely diagnose and reclaim storage on your self-hosted server without accidentally deleting critical family photos or vital application data. Master targeted cleanup techniques, tame runaway container logs, and optimize your Docker storage management like a pro.
Diagnosing Docker Disk Exhaustion
Your server has plenty of RAM. CPU usage looks fine. Then an update fails, a database starts complaining, and Docker tells you there is no space left. A full disk has a talent for making unrelated applications look broken at the same time.
Before you reach for a giant prune command, find out what filled it. Docker stores several kinds of data, and they do not all have the same value. An old build cache can usually be rebuilt. The only copy of your family photos cannot.
Start here: Run the inspection commands first. Do not delete anything inside Docker’s storage directory by hand, and do not prune volumes just because Docker calls them unused.
1. Confirm Which Filesystem Is Full
These commands only inspect storage:
df -h
df -i
docker info --format '{{.DockerRootDir}}'
docker system df -v
Read them together.
df -hshows filesystem capacity and free space.df -ichecks inodes, the filesystem’s ability to track individual files.DockerRootDiridentifies where this Docker engine stores its data.docker system df -vbreaks down Docker objects in more detail.
You can run out of inodes while still having free gigabytes. Millions of tiny files deserve a different investigation from one enormous video archive. Do not assume Docker lives on the root filesystem, or that its data directory is always /var/lib/docker. Confirm the path first.
2. Sort the Space Into Useful Categories
| Category | What it contains | How to approach it |
|---|---|---|
| Images | Application layers downloaded or built | Keep the versions needed for current services and rollback |
| Build cache | Material reused by later builds | Often reclaimable, at the cost of slower rebuilds |
| Container writable layers | Files written outside mounted storage | Inspect before removing the container |
| Volumes and bind mounts | Databases, uploads, configuration, media | Treat as application data |
| Logs | Container output and host journal entries | Fix rotation and excessive logging |
Docker’s usage report is not a complete map of every byte on the host. Bind-mounted files can live elsewhere, and container logs need their own attention.
On a Linux host, a shallow directory-size check helps locate the big folders:
docker_root="$(docker info --format '{{.DockerRootDir}}')"
sudo du -xhd1 "$docker_root"
sudo journalctl --disk-usage
The first command may take time on a busy server. Avoid repeatedly scanning a large disk while it is already struggling. Also check the actual bind-mount paths shown in your Compose files or deployment platform. A media directory under /srv will not become smaller because you cleaned an image cache.
Advanced Troubleshooting for Self-Hosters
3. Check for a Container Writing Into the Wrong Place
Run:
docker ps -a --size
If an application’s writable layer is unexpectedly large, inspect its mount configuration and application settings. It may be writing downloads or uploads to a path that you forgot to mount.
A healthy example is an application writing to /app/uploads with persistent storage mounted at exactly that destination. A broken example is mounting /uploads while the application continues writing to /app/uploads.
Do not “fix” the problem by deleting and recreating the container. First preserve the files from the actual write location and plan the migration to the intended storage path. This is particularly important when the application has been working for months. Working does not prove its data was persistent.
4. Put a Limit on Container Logs
Inspect the logging configuration of one container, replacing CONTAINER_NAME with its real name:
docker inspect --format '{{json .HostConfig.LogConfig}}' CONTAINER_NAME
The json-file logging driver can grow without a size limit unless rotation is configured. For a Compose-managed service, merge this into that service’s existing definition. It is a logging fragment, not a complete Compose file:
services:
app:
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
This bounds that container’s retained Docker logs to roughly three ten-megabyte files, with some implementation overhead. It does not cap application log files written into a volume.
Validate the Compose file:
docker compose config --quiet
Then, during an appropriate maintenance window, recreate only the affected service:
docker compose up -d --no-deps --force-recreate app
Confirm the service’s persistent data is mounted before doing this. Recreation removes the old container’s writable layer and can briefly interrupt the service. For an application managed by Coolify or another platform, make the change in that platform’s supported configuration and redeploy there. Avoid creating a second, competing deployment from the host terminal. Changing the daemon’s default logging settings alone does not retroactively change existing containers.
5. Reclaim Disposable Space Deliberately
Once you know the cause, choose a narrow cleanup. Inspect dangling images:
docker image ls --filter dangling=true
If they are no longer needed, remove that category with the confirmation prompt intact:
docker image prune
For old build cache:
docker builder prune --filter "until=168h"
That example targets eligible cache older than a week. Review the prompt before agreeing. The next build may take longer.
Keep a known working application image available while you validate an upgrade. An aggressively cleaned server with no useful rollback version can turn a small problem into an evening project.
“Unused volume” means no current container references it. It does not mean the contents are unimportant. A removed application can leave its only database copy in an unused volume.
If you have almost no free space left, pause new deployments and large imports. Reduce the activity that is still generating files. Look for one clearly identified, disposable item: an old build cache, a duplicate download, or a local backup whose independent copy you have already verified. Reclaim enough room to work, then address the underlying cause.
Avoid deleting active Docker log files, database files, or random directories under Docker’s root. Those are managed by the application or Docker engine. If inodes are exhausted, identify the directory producing huge numbers of small files. Freeing one large image may barely affect the problem.
6. Confirm That the Applications Recovered
Repeat the capacity checks and test the services that failed:
df -h
df -i
docker system df
docker ps
Then perform a real action in each affected application: open an existing record, upload a small file, or complete a harmless test request. Check logs for continuing write errors. A database that failed while the disk was full may need more attention than a container restart.
Finally, set a capacity alert early enough to act. A sensible threshold depends on growth rate: ten gigabytes free means something different on a quiet server than on a box importing camera footage. The useful outcome is a known cause, recovered services, and a limit or alert that prevents the same surprise.
Pro-Tip for Self-Hosters: Modern tools like Homepage or Uptime Kuma can integrate with your Docker socket to monitor disk usage and container health in real-time, giving you proactive warnings before a full disk triggers downtime.
FAQ
-
Question 1: Is it safe to run `docker system prune -a` when my server runs out of space?
Answer 1: Running a blanket prune command is risky for any self-hosted infrastructure. While it reclaims space by removing unused containers and images, it can accidentally wipe out stopped utility containers or base images you rely on for rollbacks. Always inspect your storage categories first and perform targeted cleanups. -
Question 2: How can I prevent Docker logs from filling up my disk in the future?
Answer 2: You can permanently prevent log bloat by defining global logging drivers in your Docker daemon configuration (/etc/docker/daemon.json) or by specifyingmax-sizeandmax-fileparameters directly inside your Docker Compose files for each individual service. -
Question 3: What should I do if my Docker volumes are taking up all my storage?
Answer 3: Docker volumes often contain critical databases and persistent user files. Before deleting any volume labeled as “unused,” use inspection tools to verify whether it belongs to a decommissioned application whose data you might still need. Migrate persistent data to a dedicated backup location before purging.





