If we do not want to find dangling images and remove them one by one, we can use the docker image prune command. This command removes all dangling images. If we also want to remove unused images, we can use the -a flag. The command will return the list of image IDs that were removed and the space that was freed.
In some cases (like in my case) you may be trying to delete an image by specifying the image id that has multiple tags that you don't realize exist, some of which may be used by other images. In which case, you may not want to remove the image.
If you have a case of redundant tags as described here, instead of docker rmi <image_id>
use docker rmi <repo:tag>
on the redundant tag you wish to remove.
You should try to remove unnecessary images before removing the image:
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
After that, run:
docker rmi c565603bc87f
all previous answers are correct but here is one solution which is just deleteing all of your images forcefully (use this command at your own risk it will delete all of your images)
docker rmi $(docker images -q) -f
find the image id and parent id for all image created after the image in question with the following:
docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=<image_id> -q)
Then you call command:
docker rmi {sub_image_id}
"sub_image_id" is ID of dependent image
What worked to me was to use the REPOSITORY:TAG combination rather than IMAGE ID.
When I tried to delete a docker image with the command docker rmi <IMAGE ID>
with no containers associated with this image I had the message:
$ docker rmi 3f66bec2c6bf
Error response from daemon: conflict: unable to delete 3f66bec2c6bf (cannot be forced) - image has dependent child images
I could delete with success when I used the command docker rmi RPOSITORY:TAG
$ docker rmi ubuntu:18.04v1
Untagged: ubuntu:18.04v1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With