Remove Docker images no more used

How to go from the following:

to:

easily ?

Just run the following commands (and ignore the warnings and errors ...):

$ docker ps -a -q --filter "status=exited" | xargs docker rm
$ docker rmi `docker images --filter "dangling=true" | awk '{ print $3 }' | grep -v IMAGE`

The magic here is the --filter flag of docker which allows us to filter the existing images and select only the one which are in status exited (so no running).