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

Posted on

Introduction

Another article which is focusing on one of the function exist by using the ‘docker’ command. It is function of removing or deleting the docker image available in the local device. In this case, the local device is running using Microsoft Windows operating system. Basically, another article with similar contain has appear in the previous one. It is an article with the title of ‘How to Delete Docker Image using docker Command in Microsoft Windows’ in this link. Well, it is using the command ‘docker image prune –force –all’. Basically, as it exist in the documentation of the command. So, the ‘prune’ parameter for the ‘docker image’ is removing some unused images including the dangling ones. In this context, the dangling one is the one where it does not have any name at all. In other words, a dangling docker image is an image where it does not have a name so far. It exist in the following list of docker images :

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

C:\repository\docker\wordpress>
C:\repository\docker\wordpress\build>docker image list --all
REPOSITORY TAG IMAGE ID CREATED SIZE

C:\repository\docker\wordpress\build>

How to Remove Dangling or Unused Docker Image using docker image Command

After looking at the output of the command execution in the previous part for listing docker image, the following after is a command for removing all of those docker images. In several previous articles, there is a command execution using ‘docker image prune’ in this link. That previous article is an article with the title of ‘How to Remove Dangling or Unused Local Docker Image using docker image prune Command in Microsoft Windows’. Moreover, in other previous article, there is a content showing how to remove unused docker image with another command. That command is ‘docker rmi’ and it exist in an article in this link. That is an article with the title of ‘How to Remove Dangling or Unused Local Docker Image using docker rmi Command in Microsoft Windows’. So, the following is the execution for removing all the above docker image. Specifically, images which is dangling or do not have any name with the fresh created docker images which have names. Use just 1 (one) digit of the image id attribute as the parameter for the command. In this context, there are several parameter given which is representing each docker image for each digit as follows :

C:\repository\docker\wordpress>docker image rm c 7 2
Untagged: wordpress:latest
Deleted: sha256:c46ad5ea445b8640bdf9d810dfa01679159a22778cf57c64097e4139dea3943f
Untagged: mysql:5.7
Deleted: sha256:77811e598d43121a29800e2ae03afdda569c3a7b95927631527f30c3c56492f7
Deleted: sha256:26fca947bf02558b628824e3e38fa1c97dbfc6c4562b2be07026281ff9019509

C:\repository\docker\wordpress>

Finally, after executing the above command for removing the docker image using ‘docker image rm’, just execute the command for listing docker images once more as follows :

C:\repository\docker\wordpress>docker image list --all
REPOSITORY TAG IMAGE ID CREATED SIZE

C:\repository\docker\wordpress>

2 thoughts on “How to Remove Dangling or Unused Local Docker Image using docker image Command in Microsoft Windows

Leave a Reply