A Docker Image That Cannot Be Deleted

conflict: unable to delete

* This page contains promotional content

Symptoms

I tried to delete an image file in Docker and got an error

$ docker rmi d56
Error response from daemon: conflict: unable to delete d562087633bf (cannot be forced) - image has dependent child images

Forcing the deletion

$ docker rmi d56 -f
Error response from daemon: conflict: unable to delete d562087633bf (cannot be forced) - image has dependent child images

Cause

The error seems to say that child image files depend on it.

Specifying the repository name and tag name rather than the ID sometimes lets you delete it

$ docker rmi  REPOSITORY:TAG
or
$ docker rmi -f REPOSITORY:TAG

If that deleted it for you, the rest below is unnecessary
If it still cannot be deleted, look into the dependent files
(The image I wanted to remove here is d56, so change it as appropriate)

$ for i in $(docker images -q)
do
    docker history $i | grep -q d56 && echo $i
done | sort -u

Result

ab51490dbf8a
d562087633bf

Besides d562087633bf, ab51490dbf8a was listed

Deleting them

$ docker rmi ab5 d56

Reference article