Recently I tried to spin up a new container and Docker refused with this error:
OSError: [Errno 28] No space left on device:
Not the most helpful message, but the root cause was simple: the disk used by the Docker engine was full.
As you can see in the screenshot below, I was eating up almost the full 250GB available for Docker:
Where did my disk space go?
Before deleting anything, let's find out what is actually using the space. Docker has a built-in command for this:
docker system df
This gives you a summary of the space used by images, containers, local volumes and build cache. Want more detail per item? Add the verbose flag:
docker system df -v
In my case, the usual suspects were to blame: old images, stopped containers and build cache that had been piling up for months.
Cleaning up
Start with the safest options and work your way up.
- Remove all stopped containers:
docker container prune
- Remove dangling images (untagged layers that are no longer referenced):
docker image prune
- Remove all images not used by at least one container:
docker image prune -a
- Remove the build cache:
docker builder prune
- Or do everything in one go:
docker system prune -a
Remark: docker system prune does not touch volumes by default. That is on purpose, as volumes usually contain data you want to keep. You can add --volumes or run docker volume prune, but double-check what's inside first. Deleted volume data is gone.
Remark: docker image prune -a also removes images you might need again tomorrow. The next docker pull or docker build will take longer, but nothing is lost.
Trying again
After the cleanup I ran docker system df again to confirm the space was reclaimed, and started my containers again:
docker compose up
This time it started without complaints. Problem solved!

