2

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.

Crystal
  • 28,460
  • 62
  • 219
  • 393

2 Answers2

3

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"`
Jiri Kremser
  • 12,471
  • 7
  • 45
  • 72
  • Thanks for the tip. I found a dozen `exited()` containers. I don't know why they are still there. They might use a lot disk space (I'm using SSD, holy) – stanleyxu2005 Nov 02 '15 at 05:08
2

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

seanmcl
  • 9,740
  • 3
  • 39
  • 45