Unable to remove docker image

I've been playing around with building Docker images and noticed I had a few that had <none> as both the repository and tag info.

% docker images

REPOSITORY                 TAG                 IMAGE ID	...

<none>                     <none>              c1e0e48a03bb  
<none>                     <none>              c8bf15029bc0 

I tried to delete these untagged images, but couldn't.

% docker rmi c1e0e48a03bb
Error response from daemon: Conflict, cannot delete c1e0e48a03bb because the container 5f266c452a8b is using it, use -f to force

Ok, so we'll try to force deletion.

% docker rmi -f c1e0e48a03bb
Error response from daemon: No such id: b5dc67806c5f1e4abfa079a1c99f6d782e5696a25a3c9beb16043fe2e7164d19
2014/10/18 10:04:27 Error: failed to remove one or more images

Mmm ... the original message said the image couldn't be deleted because it was in use by a container. I didn't have any running containers as I verified by doing docker ps. But the issue is that docker holds on to images even from exited containers. Once you realize that, then this becomes much easier to resolve.

To delete all your exited containers.

% docker ps -a -q --filter "status=exited" | xargs docker rm

And to then delete all your untagged images.

% docker rmi `docker images -q --filter "dangling=true"`

tags: docker

Comments

comments powered by Disqus