Docker: Remove Image – Remove All Images – Remove Unused

To delete a particular Docker image firstly you have to find out the IMAGE ID by listing the all local Docker images.

When the image for deletion is identified it can be removed with the docker rmi command.

From the command-line it is also possible to remove unused Docker images (not used by any containers) or, if it is needed, you can force removal of the all locally downloaded Docker images.

List Docker Images

List all locally downloaded Docker images:

$ docker images

Remove Docker Image

Remove Docker image by IMAGE ID:

$ docker rmi <image>

Force removal of the Docker image:

$ docker rmi -f <image>

Remove Unused Docker Images

Remove all unused Docker images:

$ docker image prune -a -f

Remove All Docker Images

Force removal of the all Docker images:

$ docker rmi -f $(docker images -q)

Cool Tip: If you get an error message that it is unable to delete an image because it is used by running container or it has dependent child images – try to remove Docker containers first! Read More →