Seeing Docker no space left on device is stressful. Many guides tell you to run docker system prune -a --volumes. On a server with a database, that command can be risky. This quick fix shows you how to find what uses the space, remove only safe data, and keep your volumes.
Fix Docker No Space Left on Device Without Deleting Your Volumes
Table of Contents
- Step 1: Check Disk Blocks and Inodes
- Step 2: Check What Docker Is Using
- Step 3: Decide What Is Safe to Remove
- Step 4: Clean the Docker Build Cache
- Step 5: Clean Unused Images and Stopped Containers
- Step 6: Find and Limit Large Container Logs
- Step 7: Check Your Volumes
- Step 8: Disk Usage Before and After Cleanup
- Step 9: Rebuild the App and Verify the Database
- Free Docker Disk Space Safely: Cache, Logs, and Images
- Conclusion

Step 1: Check Disk Blocks and Inodes
This error can have two causes, which are no free space or no free inodes. Inodes are the file slots on a disk. You can check both with the commands below:
- If
Use%is 100% indf -h, the disk blocks are full. - If
IUse%is 100% indf -i, you have too many small files. Free space can still show as available.
You can find which mount is full with the commands below. Docker usually stores data in /var/lib/docker:
Tips: If you do not have a Linux server yet for Docker work, a Linux VPS with NVMe storage and full root access gives you a clean base to test these steps.
Step 2: Check What Docker Is Using
Now check how much space Docker itself uses. The docker system df command shows the size of your images, containers, volumes, and build cache. It helps you find what takes the most space, and it is the main command for docker system df reclaim space tasks. Run it before you delete anything:
Here are the four types of data:
The RECLAIMABLE column shows how much space Docker says you can free. Be careful with the number for volumes. A volume that no container uses right now can still hold your only copy of the data.
Step 3: Decide What Is Safe to Remove
Not everything Docker stores is safe to delete. Build cache and unused images are easy to get back. Volumes and some logs may hold data you need. Use the table below to match what you see with the right action:
Step 4: Clean the Docker Build Cache
When the "docker build cache disk full" problem happens, it is the safest one to fix. The build cache only makes builds faster. If you delete it, Docker makes it again the next time you build.
You can remove cache that is older than 24 hours with:
If you need more space, remove all unused cache:
Check the results with the commands below:
Step 5: Clean Unused Images and Stopped Containers
Old images and stopped containers also take up space on your disk. Most of them are safe to remove, but you must check them first. List what you have with the command below:
Then, remove stopped containers and unused images:
docker image prune -a removes images that no container uses. Docker will download or rebuild them later if needed.
Step 6: Find and Limit Large Container Logs
Container logs can grow very large over time. By default, Docker does not limit their size. A single busy container can fill your disk with log files. First, find the biggest logs with:
Then, find the log file of one container:
Now run the command below to empty the log without deleting the file:
At this point, you must set up log rotation. This tells Docker to keep logs small. Open the Docker config file:
If the file is empty or new, paste this:
Note: If the file already has settings, do not delete them. Add only the log-driver and log-opts lines inside the existing { }, and put a comma between each setting.
This keeps up to 3 log files of 10 MB each for every container.
Save the file and exit. Then, check that the JSON is valid:
If you see your settings printed back, the file is correct. Next, restart Docker:
Restarting Docker stops your containers unless live-restore is on. Do this in a quiet time.
The new limit only applies to new containers. Existing containers keep their old settings, so you must recreate them. Verify one container:
You should see max-size and max-file in the output.
Step 7: Check Your Volumes
Volumes store your app data, such as databases and uploaded files. If you delete a volume, you may lose that data. So you must check what each volume holds before you run any cleanup command on it.
List volumes and check their size with the commands below:
Find which container uses a volume:
Check where a volume is stored:
On Docker 23 and later, docker system prune --volumes removes only unused anonymous volumes. Named volumes stay safe unless you run docker volume prune -a. But anonymous volumes can also hold database data. So the rule is to check what each volume holds before you run any volume prune command.
Never run this on a server with real data:
Tips: If your data is large and keeps growing, you can move it to bigger storage. A Storage VPS with 1 TB to 4 TB of HDD is a good place for backups and archives, so your main disk stays free.
Step 8: Disk Usage Before and After Cleanup
Here is an example of a safe cleanup. First, we check the disk usage, remove only the safe data, and then check again. The numbers come from a test server, so yours will differ. Notice that the volumes stay the same.
The Local Volumes line has the same size as before. This means we did not remove any volumes, so your data is still there.
Step 9: Rebuild the App and Verify the Database
After the cleanup, you must rebuild your app to make sure everything still works. This also checks that your database data is still there. Do not use the -v option, because it deletes your volumes:
Check that the containers run:
Check that the volume is still attached and has data:
Change db and the path in the command to match your own database. Then, open your app and check that your old data is still there.
Note: If this happens on a Coolify server, the same disk checks also apply. Check the Coolify troubleshooting guide for stuck builds and deploy problems.
Free Docker Disk Space Safely: Cache, Logs, and Images
Cleaning the disk once is not enough. Build cache and logs grow again with time. A few simple checks will keep your server healthy and stop this error from coming back:
- Set log rotation in
daemon.json. - Run
docker builder prune --filter "until=168h"once a week. - Check
df -handdocker system df. - Keep backups of important volumes on another server.
If your disk is always near full after cleanup, your real data is growing. At that point, you must pick a plan with more disk. Compare NVMe sizes on a Linux VPS plan or move backups to a Storage VPS.
Conclusion
To fix Docker no space left on device, run df -h and df -i to check disk space and inodes. Then, run docker system df to see what uses the space. Next, clean the build cache, unused images, and big logs. Keep your volumes unless you are sure you can delete them. Last, set up log rotation and rebuild your app to check that your database is still there.
No, not by default. With --volumes, it removes only unused anonymous volumes on Docker 23 and later.
Yes. Docker will rebuild it. Your next build may be slower.
The space may be used by logs, other apps, or inodes. Check df -i and du.
No. You must recreate the containers to apply the new limit.
No. Only docker compose down -v deletes them.
Only if you checked that every unused volume is disposable.