[SOLVED] Docker: How to delete images tagged as repository and tag <none>?

When we often rebuild the application image, which is marked with the same tag, e.g. latest, we encounter the problem that our image registry (Docker registry) will have many images that will be marked as .

The problem we encounter then is a troublesome registry cleaner from this rubbish. Removing them one by one can give us a lot of nerves and we will lose a lot of time (it is such a “stupid” job).

Delete one by one

Let’s look at the following repository list:

docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
python                      3                   0a3a95c81a2b        12 days ago         932MB
<none>                      <none>              871503ecbdc9        4 weeks ago         392MB
sonarqube                   latest              d7558a6a8598        2 months ago        479MB
redis                       5.0.5               63130206b0fa        2 months ago        98.2MB
postgres                    9.6                 61c59b9a763f        2 months ago        230MB
postgres                    latest              e2d75d1c1264        2 months ago        313MB
mysql                       5.7                 383867b75fd2        2 months ago        373MB

To delete the selected image, we can use the command:

docker image rm <IMAGE_ID>

In the example below, I will remove the redis image and I will leave for the next example.

# Delete redis image
docker image rm 63130206b0fa

pawel@pawel:~$ docker image rm 63130206b0fa
Untagged: redis:5.0.5
Untagged: redis@sha256:5dcccb533dc0deacce4a02fe9035134576368452db0b4323b98a4b2ba2d3b302
Deleted: sha256:63130206b0fa808e4545a0cb4a1f14f6d40b8a7e2e6fda0a31fd326c2ac0971c
Deleted: sha256:9476758634326bb436208264d0541e9a0d42e4add35d00c2a7408f810223013d
Deleted: sha256:0f3d9de16a216bfa5e2c2bd0e3c2ba83afec01a1b326d9f39a5ea7aecc112baf
Deleted: sha256:452d665d4efca3e6067c89a332c878437d250312719f9ea8fff8c0e350b6e471
Deleted: sha256:d6aec371927a9d4bfe4df4ee8e510624549fc08bc60871ce1f145997f49d4d37
Deleted: sha256:2957e0a13c30e89650dd6c00644c04aa87ce516284c76a67c4b32cbb877de178

Delete all <none> images

To delete all images with tag and repository use the command below:

docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

As a result of the command you will receive information about what has been deleted:

Deleted: sha256:871503ecbdc9f2f2bb2989af6440d34b0eef684b730d317680a8440813f321b5
Deleted: sha256:eb22964fbb062e908432240a2d12a448e75db2081481422c2908ec7875074a00
Deleted: sha256:bdc87704af3a50bd53ae32edef6c7f020b8f144c7ab9b227a9905223a0e0885f
Deleted: sha256:d0cddd997d27bd75a0b75d36733e4350e5750f0d0182cd634801c579e9aba915
Deleted: sha256:1781e4eca03220934d1646f64a6d3775b935c6db2fb00474b5c8d9844e8faa1f

You can now check again if the images have actually been deleted using the command:

docker images

If you enjoyed this post please add the comment below or share this post on your Facebook, Twitter, LinkedIn or another social media webpage.
Thanks in advanced!

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments