docker rmi $(docker images -f dangling=true -q)
Removes dangling Docker images.
You might free up even more space by removing all unused images, which encompass dangling images, using the following command:
docker system prune --all
make-space opts for a more conservative strategy and only removes dangling Docker images.
Read this StackOverflow answer regarding the difference between dangling and unused images:
An unused image means that it has not been assigned or used in a container. For example, when running
docker ps -a- it will list all of your exited and currently running containers. Any images shown being used inside any of containers are a "used image".
On the other hand, a dangling image just means that you've created the new build of the image, but it wasn't given a new name. So the old images you have becomes the "dangling image". Those old image are the ones that are untagged and displays "
<none>" on its name when you run