Originally published at deepu.tech.
Cleanup your Docker setup
If you are using Docker on your PC or Mac, over time it is gonna accumula...
For further actions, you may consider blocking this person and/or reporting abuse
Nice function, but did you know Docker has it's own clean up mechanism? It's called "docker system prune" and it's available since api version 1.25. It can be used to remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes.
By default it will remove all stopped containers, all networks not used by at least one container, all dangling images and all build cache.
When adding the
-a
and--volumes
parameters it will remove all stopped containers, all networks not used by at least one container, all volumes not used by at least one container, all images without at least one container associated to them and all build cache.Wow cool. I didn't know that and when I was originally writing this function few months ago it never came up in any of the resources I found. Cool. I'll try it out.
Well talk about making the entire post irrelevant 😉
I don't think its irrelevant at all. The
system prune
command only works when you want to clean your entire docker setup. All these commands give you more control when you want to clean only certain parts of your docker setup.my actual command:
from github.com/m1well/env-setup
Seems like you can combine 2 and 3 with --volume flag, 4 never worked for me, don't know why
Thanks for that handy little scripts.
Can you tell the difference to
docker system prune
?As I mentioned in another comment. I wasn't aware of it. I need try it and compare. Once I do I'll update the post
Really respect people who produce posts likes this one. Simple, Focused and Effective. Thank you
Thank you