Crystal
Crystal

Reputation: 29518

cannot remove docker image, error response from daemon

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.

Upvotes: 2

Views: 4198

Answers (2)

Jiri Kremser
Jiri Kremser

Reputation: 12857

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"`

Upvotes: 4

seanmcl
seanmcl

Reputation: 9944

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].

Upvotes: 2

Related Questions