cannot remove docker image, error response from da

2019-08-05 06:28发布

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.

标签: docker
2条回答
干净又极端
2楼-- · 2019-08-05 06:56

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

查看更多
小情绪 Triste *
3楼-- · 2019-08-05 07:02

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"`
查看更多
登录 后发表回答