cannot remove docker image, error response from da

2019-08-05 06:50发布

问题:

I'm pretty new to ubuntu so there is probably something simple I am missing. I am trying to remove my docker images with

sudo docker rmi <IMAGE ID>

I get the error

Error response from daemon: No such Id: 265fdadf...

If I try

sudo docker ps -a | grep <Image ID>

It does not return any results.

I'm not sure what this error response means and why I cannot delete the image. The Id 265 is different than the actual IMAGE ID of my docker image.

回答1:

You're confusing containers with images. When you do docker ps, you're asking docker to display the running containers. When you do docker rmi you're asking docker to remove images. To list the images, do docker images [-a].



回答2:

The issue (at least for me) was that in Docker the containers that are exited keep the reference to images, so that those images can't be deleted. That's why docker ps -a is not enough.

So for deleting all the images use these two steps:

sudo docker ps -a -q --filter "status=exited" | xargs sudo docker rm
sudo docker rmi `sudo docker images -q --filter "dangling=true"`


标签: docker