On my development machines, I need docker most of the time...
The annoying parts are:
- take a shit ton of place on my SSD for images and unused containers. Like 200GB
- add a lot of virtual network interfaces.... around 50 useless interfaces polluting my computer.
I won't uninstall docker but I would like to remove all containers, all volumes, all networks, and all volumes.
Start by stopping all running containers.
sudo docker stop `docker ps -qa`
then delete all containers (running and stopped)
sudo docker rm `docker ps -qa`
then remove all networks not used by at least one container. None are left so we are removing all of them...
sudo docker network prune
Now we will remove all the volumes:
sudo docker volume prune
And finally, we can remove all the images:
sudo docker images prune
Enjoy the space and silence.
ps: If you are only looking to remove unused resources go with
sudo docker system prune
pps: If you are only looking to remove stopped container
docker container prune -f thanks to Manuel Castellin for the tips.
Top comments (2)
@webeleon great idea sharing these tips! Lots of people will enjoy some additional free space!
Also, as a quick daily cleanup you can use the following to "remove all stopped containers":
I'll add that command to the memo