Remove dangling docker images and stopped containers. Cross platform solution.

twitter logo github logo ・1 min read

I know there are a lot of solutions for this, however if you need cross platform solution working both for for Windows and Linux OS, just use small and nifty sparrow plugin docker-remove-dangling-images:

$ sparrow plg install docker-remove-dangling-images
$ sparrow plg run docker-remove-dangling-images

Best

Alexey

twitter logo DISCUSS (8)
markdown guide
 

why just do not create function for that? or even alias

 

A few points:

  • how about windows?
  • if you move to another machine you will need to deploy all the bash functions, aliases again ... and when you create scripts this way you tend to do it woking in my machine, hard to port, deliver and maintain ...

I know there is dot files and GH, but this only works well for very "simple/one time purposes" scripts, reality is eventually any script gets more complicated and needs proper distribution mechanism.

 

On windows i personally use git-bash
as i looked (hopefully on right source) everything is oneliner, so i do not see point of installing something, what is as long as command itself

end actually, i think most people would need to install sparrow. (never heard of it)
imho overkill

  1. I don't want to install git bash for the sake of running simple script.

  2. My point is that everything that starts as one liner command eventually might turn in more complicated script.

Well, you are fine as long as you create something that is working only for you and your environment.

While idea behind the Sparrow is portable scripts for community which get installed and run without any fuss.

The real benefit of using Sparrow is that you develop script with distribution and maintenance in mind rather then creating one time solutions which only works for you.

maybe i will check out sparrow someday, doesnt sound bad...

ad 1. if you use git (which you should), you have git-bash already installed

 

Why not just use the official way:

docker container prune -f
docker image prune -f
 

Hi @Paulius, thanks for suggestion, fixed at version 0.0.8:

$ sparrow plg run docker-remove-dangling-images --nocolor
sparrow root: [C:\Users\melezhik/sparrow]
Total reclaimed space: 0B
Deleted Images:
deleted: sha256:579734eacb77553190fb716ba4c9820eac568316912336c9f8e0d62149790ca9
deleted: sha256:b5bb98175c85070b93b0b495babbbae30b783b72c913f22b13f4365557bdac40

Total reclaimed space: 634.4MB
STATUS  SUCCEED
Classic DEV Post from May 3

What do you code to relax?

My projects have me jumping through hoops of a wide variety of technology, talkin...

Alexey Melezhik profile image
Sparrow6 - Raku Automation Framework

Signed up yet?

DEV is one of the most important resources in software.

Create Your Account