Reputation: 1547
I am running docker on windows 10.
I had a couple of images stored in my machine. The total size of these images accumulated to around ~10GB. I have deleted these images via 'docker rmi -f
' command.
But the space occupied by these images has not been released. If I run 'docker images' command, the deleted images are not listed in the output of 'docker images' command(but the disk space is not cleaned up).
How can I improve (ie. reduce) the disk space used by docker?
Upvotes: 96
Views: 122503
Reputation: 11173
In addition to the use of docker prune -a
, be aware of this issue: Windows 10: Docker does not release disk space after deleting all images and containers #244.
It is a frighteningly long and complicated bug report that has been open since 2016 and has yet to be resolved, but might be addressed through the "Troubleshoot" screen's "Clean/Purge Data" function:
I have just used this to re-claim 100 gig.
WARNING: This of course deletes all the data concerned.
Upvotes: 6
Reputation: 1256
First to find out what is using the space:
docker system df
see docs
In my case most of it was used by "Build cache", to remove it:
docker builder prune
see docs
Upvotes: 19
Reputation: 10153
My disk was used 80%, but a calculation of file sizes on the disk showed about 10% of usage.
In my case cleaning docker caches, volumes, images, and logs not helped. But helped restart of docker service:
sudo systemctl restart docker
After this usage of the disk has become equal to the expected 10%.
Upvotes: 3
Reputation: 8824
On windows with docker desktop running on wsl2 there is an option in GUI to purge data.
select wsl2 when prompted for data store.
Note: This option will remove all of your docker data. If you don't wish to do so then try the prune option mentioned by others in this thread.
Upvotes: 13
Reputation: 620
If your space is full in my experience docker prune will just hang. You need to manually delete the volumes.
Upvotes: 2
Reputation: 14222
First try to run:
docker system prune
It will remove:
If that's not enough, do:
docker system prune -a
It will remove:
If you haven't got what you expected, try the following
docker volume prune
It will remove all local volumes not used by at least one container.
Upvotes: 135
Reputation: 5908
docker system prune
works perfectly on my machine running Ubuntu 20
and docker 20.10.2
.
Upvotes: 0
Reputation: 551
To clean the system memory there are three steps:
This worked for me. Around 30gb of space was cleaned after doing the above mentioned steps.
Upvotes: 5
Reputation: 1328152
Update Q4 2016: as I mention in "How to remove old and unused Docker images", use:
docker image prune -a
(more precise than docker system prune
)
It will remove dangling and unused images.
Warning: 'unused' means "images not referenced by any container": be careful before using -a
.
Then check if the disk space for images has shrunk accordingly.
Original answer:
See the Medium article "How to clean up Docker (~5GB junk!)" from katopz
.
It refers to the docker-cleanup
script, for removing old exited process, and dangling images.
I have my own aliases as well.
But it also mentions that, since docker 1.10, you now have named volumes that need to be removed as well:
docker volume rm $(docker volume ls -qf dangling=true)
Upvotes: 23