How to Remove Dangling or Unused Local Docker Image using docker rmi Command in Microsoft Windows

Posted on

Introduction

Another article which contains similar subject with several previous articles. The first article is the one with the title of ‘How to Remove Dangling or Unused Local Docker Image using docker image command in Microsoft Windows’ which exist in this link. In that article, it is using the ‘docker image prune’ format. Using that command format, it is able to remove or to delete all of the dangling or unused docker images at once. And the second one is the article with the title of ‘How to Delete Docker Image using docker image Command in Microsoft Windows’ in this link. Before getting to that docker image removal process, just execute the command for listing the docker image as follows :

C:\repository\docker\wordpress>docker image list --all
REPOSITORY TAG    IMAGE ID     CREATED      SIZE
wordpress  latest c46ad5ea445b 3 hours ago  609MB
mysql      5.7    77811e598d43 26 hours ago 462MB
<none>     <none> 26fca947bf02 5 years ago  436MB
C:\repository\docker\wordpress>

How to Remove Dangling or Unused Local Docker Image using docker rmi command

In this part, the focus is just on the process for showing how to remove dangling or unused docker image. Moreover, in the previous article, it has been a success to remove dangling or unused docker images using ‘docker image prune’. But in this part, it will use another command. It will use the ‘docker rmi’ command. This command uses image id as an additional parameter. That image id is chosen to decide which are selected images for further removal. So, the following is an example using 1 (one) digit of the image id :

C:\repository\docker\wordpress>docker rmi c 7 2
Untagged: wordpress:latest
Deleted: sha256:c46ad5ea445b8640bdf9d810dfa01679159a22778cf57c64097e4139dea3943f
Untagged: mysql:5.7
Deleted: sha256:77811e598d43121a29800e2ae03afdda569c3a7b95927631527f30c3c56492f7
Deleted: sha256:26fca947bf02558b628824e3e38fa1c97dbfc6c4562b2be07026281ff9019509
C:\repository\docker\wordpress>docker image list --all
REPOSITORY TAG IMAGE ID CREATED SIZE
C:\repository\docker\wordpress>

As in the last output of the command execution, there are no longer docker images exist. In other words, the removal process of the docker images using the command ‘docker rmi’ is a success.

Leave a Reply