$ docker images -q -f dangling=true | xargs --no-run-if-empty --delim='\n' docker rmi ExplanationIt 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. LimitationsThis only works in the GNU version of |