Removing dependent child images

Anju
Apr 4, 2021

--

If you cannot remove an image even with “-f” option generating below error then you need to first find out the dependent images and delete them first.

[root@worker Prometheus]# docker rmi -f 109b803c6a30
Error response from daemon: conflict: unable to delete 109b803c6a30 (cannot be forced) - image has dependent child images
#Below command will list down the child images (Put your parent image id instead of 109b803c6a30)docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=109b803c6a30 -q)#Use below script to remove all the child imagesfor i in `docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=109b803c6a30 -q)|awk -F":" '{print $2}'`; do docker rmi $i; done

--

--

Anju
Anju

Written by Anju

A DevOps engineer who loves automating everything (almost), exploring new places, and finding peace in nature. Always looking for the next adventure!

No responses yet