Remove all unused Docker images

Running out of disk space on your Docker host? Here is a quick one liner to remove all unused Docker images:

docker images -q |xargs docker rmi

It will error on images that a running container is using, and won’t delete it.

I found this little gem in the Docker forums here:

Docker forums