How To Remove Dependent Child Images Of A Docker Container


Problem Statement:
  Deleting an image from docker container was giving me an error message :

"unable to delete <Image ID> (cannot be forced) - image has dependent child images"

I tried multiple solution but nothing worked.

The Solution:

To find out all the dependent images use the below mentioned command:


docker inspect --format='{{.Id}} {{.Parent}}' $(docker images --filter since=<ImageID> -q)


Please note : 

Image ID is the Identifier of image, which can be find out using command 


docker image -a

It will list all the images showing Image ID as well.


 
Once you get the all the dependent images, delete the child image first and then the parent image.

For deleting image following commands need to be used.

docker rmi <Image ID>

Comments