Twitter (not set)
Blog (not set)
Website (not set)

0

Delete all untagged Docker images

 $ docker images -q -f dangling=true | xargs --no-run-if-empty --delim='\n' docker rmi

— by penguincoder on June 15, 2018, 1:12 a.m.

Explanation

It does not return a failing exit code if there are no images removed. It should always succeed unless there was an actual problem removing a Docker image.

Limitations

This only works in the GNU version of xargs (thanks to the --no-run-if-empty), BSD does not have an equivalent that I know about.