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.
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.