Docker

How do I Delete Multiple Images on Docker

Docker images are referred to as a framework or template used to build the containers. These images contain instructions that help the container to dockerize and test the application or project. But as we know images contain project code, essential dependencies as well as configuration settings. Therefore, these images take up a lot of disk space. To free up the system space, users needed to remove extra, dangling, and unused images from the system.

This article will provide how to delete multiple images on Docker.

How to Delete Multiple Images on Docker?

Docker images are heavy in size and can take much of your system space and slow down the system. Users can delete unused, dangling images from the Docker platform by utilizing the listed instructions.

Step 1: List All Images

First, list down all the images using the “docker images” command. Here, the “-a” option is specifically used to list all images in Docker. Note the image id you are needed to remove from the “Image ID” column:

> docker images -a

Step 2: Remove Multiple Images

Next, remove multiple images through the “docker rmi <image-id-1>, <image-id-2>” command. Here, “-f” is used to remove the image forcefully:

> docker rmi -f 4e5a50858d3a, 30a004788ce8

Here, you can see we have successfully deleted the multiple images from “docker rmi” command:

Bonus Tip: Remove All Images in Docker

In order to remove all unused images from the Docker platform, go through the provided command. Here “-q” is used to access the image by id:

> docker rmi $(docker images -q)

For the verification, again list down all the images and check whether the images are removed or not:

> docker images -a

It can be noticed that we have successfully removed the images from Docker:

That’s all! We have demonstrated how to remove multiple images from Docker.

Conclusion

To delete multiple images on the Docker platform, utilize the “docker rmi -f <image-id 1> <image-id 2>” command. In order to remove all dangling and unused images, you can execute the “docker rmi $(docker images -q)” command. This write-up has demonstrated how to delete or remove multiple images on Docker.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.