I've the following images:
alex@alexvps:~$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
<none> <none> 70c0e19168cf 5 days ago 1.069 GB
<none> <none> c2ce80b62174 8 days ago 399.2 MB
<none> <none> 60afe4036d97 8 days ago 325.1 MB
and when I try to remove one of them I get:
alex@alexvps:~$ sudo docker rmi 60afe4036d97
Error: Conflict, 60afe4036d97 wasn't deleted
2014/01/28 00:54:00 Error: failed to remove one or more images
How can I remove them? Why is there such conflict?
You have to stop/delete all unnecessary containers created on that images first.
Have a look: How to remove old Docker containers.
After that use @marcell solution.
In Bash:
This will remove all images with name "<none>". I found those images redundant.
The reason for the error is that even though the image did not have any tag, there still exists a container created on that image which might be in the
exited
state. So you need to ensure that you have stopped and deleted all containers created on those images. The following command helps you in removing all containers that are not running:Now this removes all the dangling non-intermediate
<none>
images:Since Docker ver. 1.13.0 (January 2017) there's the
system prune
command:Use
or
Remove all dangling images. If
-a
is specified, it will also remove all images not referenced by any container.Note: You are prompted for confirmation before the prune removes anything, but you are not shown a list of what will potentially be removed. In addition,
docker image ls
does not support negative filtering, so it difficult to predict what images will actually be removed.As stated under Docker's documentation for prune.
First, remove all the containers using the following command
Then, remove the image by its ID using the following command