docker rmi cannot remove images, with: no such id

前端 未结 9 1326
感情败类
感情败类 2021-01-30 12:52

I have a lot of images. When I try to remove them with docker rmi

$ sudo docker rmi acd33a9490dc
Error response from daemon: No such id: 75ce1f6710b         


        
相关标签:
9条回答
  • 2021-01-30 13:00

    I think this is the expected behavior, not a bug. This is because you have containers hanging around that have not been deleted. These containers are instances of the image, and that is preventing you from dropping that image.

    Step 1 - remove unused container instances

    Both jripoll's answer and Andras Hatvani's answer show ways of listing and removing the containers that are bound to the images.

    Note that the latter will delete all container instances!! So, if there is one that you need to commit as a new image, you should do that first.

    Step 2 - remove unnecessary images

    After the containers have been deleted, you will be able to remove any images they were based on.

    To quickly remove any untagged containers (ones that show up as <none> <none> when you run sudo docker images) you can run the following command:

        sudo docker images -q --filter "dangling=true" | sudo xargs docker rmi
    

    I have saved that in /usr/local/bin/docker-purge-dangling so I can run it without needing to remember the command.

    0 讨论(0)
  • 2021-01-30 13:05

    Sincere appreciation to all of you. I have tried all your approaches, but was not able to delete the following image:

    [myself@testvm]$ docker images -a
    REPOSITORY    TAG     IMAGE ID      CREATED       SIZE
    hello-world   latest  c54a2cc56cbb  6 months ago  1.848 kB
    

    I had to remove it from here instead:

    sudo rm /var/lib/docker/image/devicemapper/imagedb/content/sha256/c54a2cc56cbb2f04003c1cd4507e118af7c0d340fe7e2720f70976c4b75237dc 
    

    Now it is gone.

    0 讨论(0)
  • 2021-01-30 13:06

    Running this cleanup script I made somehow magically solves this for me:

    # remove orphan containers
    docker ps -a | grep -v ":" | awk '{print $1}' | xargs docker rm -f
    
    # remove orphan images
    docker images | grep "<none>" | awk '{print $3}' | xargs docker rmi -f
    
    0 讨论(0)
  • 2021-01-30 13:09

    You may also face this issue if you do not remove exited containers. You need to remove the exited container by doing this,

    sudo docker ps -a | grep Exit | awk '{print $1}' | sudo xargs docker rm 
    

    Then remove your image using

    sudo docker rmi <imageID>
    
    0 讨论(0)
  • 2021-01-30 13:11

    Put in your terminal:

    docker ps -a
    
    CONTAINER ID | IMAGE ......................NAMES
    
    d25c0cd9725a |acd33a9490dc ................focused_einstein
    

    You can see your IMAGEID in the column IMAGE. Get the CONTAINER ID an remove the container:

    docker rm d25c0cd9725a
    

    And now you can remove the image:

    docker rmi acd33a9490dc
    
    0 讨论(0)
  • 2021-01-30 13:16

    If you need to remove several images, then you can delete all containers with

    sudo docker ps -a -q | xargs -n 1 -I {} sudo docker rm {}
    

    Now you can remove any images.

    0 讨论(0)
提交回复
热议问题