How to Remove Old and Unused Docker Images

If you need to remove any old and unused Docker images, then you can do the following:

How to Remove Old and Unused Docker Images

Firstly you need to see all the images:

docker images

You can also use ls to see the Docker Images:

docker image ls

How to Remove a Single Docker Image

The docker rmi command will remove a single Docker image as follows:

docker rmi <image_id>

You can also use the Docker image names as follows:

docker rmi ubuntu something

How to Remove Dangling Docker Images

docker images -f dangling=true

It’s also possible to prune images as follows:

docker image prune

You can also automatically find all the images and remove them directly:

docker rmi $(docker images -q -a)