How to remove multiple docker images with the same imageID?

Hadi picture Hadi · Oct 5, 2015 · Viewed 37k times · Source

I created a local docker registry and then pull some of my docker images from docker hub and then push them to the local registry. Now I want to remove my local images. But the problem here is that imageID of the images are the same and I cannot remove them. I searched for the solution but I couldn't find the solution.

>> docker images

REPOSITORY                     TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
localhost:5000/[repo1]        v-0.9.1              810001cb03af        4 weeks ago         594.6 MB
[myaccount]/[repo1]           v-0.9.1              810001cb03af        4 weeks ago         594.6 MB

as you see the image ID are the same for both images. How can I remove them?

EDIT

  • my docker version:

    Docker version 1.8.2, build 0a8c2e3

  • output of docker rmi 810001cb03af:

    Error response from daemon: Conflict, cannot delete image 810001cb03af because it is tagged in multiple repositories, use -f to force Error: failed to remove images: [810001cb03af]

  • If I do docker rmi -f 81000 it will remove both of them and I need to pull again.

Answer

user2707671 picture user2707671 · Oct 5, 2015

Here is a way you could do this. Run the command:

docker images | grep 810001cb03af | awk '{print $1 ":" $2}' | xargs docker rmi

where 810001cb03af is your image id.