Image has dependent child images [How to Solve]


Accidentally found that there are many images on the server, taking up a lot of space, want to clean it up
results delete directly and report an error

docker rmi 8f5116cbc201

Error response from daemon: conflict: unable to delete 8f5116cbc201 (cannot be forced) - image has dependent child images

Then, there are two main methods of online demand

Method 1: forcibly delete the image

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

End in failure

Method 2: Bulk delete containers, then delete the image

# Stop all containers
docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker stop

# Delete all containers
docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker rm

# Delete all none images
docker images|grep none|awk '{print $3 }'|xargs docker rmi

Or end in failure


after searching for a long time, it is found that the problem is due to tag, that is, there are other images from this image. You can use the following command to list the parent images of all images created after the specified image


query dependency first

docker image inspect — format = ‘{. Repotags} {. ID} {. Parent}’ $(docker image LS – Q — filter since = XXX) # XXX refers to the image ID

and then delete the container according to tag



Docker none image

Effective none image
the composition of docker file system, docker image is composed of many layers, each layer has a parent-child relationship, all docker file system layers are stored in/var/lib/docker/graph directory by default, docker is called layer database

Finally, make a summary < none>:< none> Image is a kind of intermediate image. We can use docker images – A to see that they will not cause the problem of hard disk space occupation (because this is the parent layer of the image and must exist), but it will confuse our judgment

Invalid none image

Another type of < none>:< none> Images are dangling images, which can cause disk space occupation problems

Programming languages like Java and golang have a memory area that is not associated with any code. The garbage collection system of these languages first reclaims the space of this area and returns it to the heap memory, so this memory area is useful for later memory allocation

Docker’s dangling file system is similar to the above principle. It is not used and will not be associated with any images. Therefore, we need a mechanism to clean up these dangling images

We have mentioned effective < none> Mirror image, they are a kind of middle layer, which is invalid < none> How does the mirror image appear? These dangling images are mainly generated by triggering the docker build and docker pull commands

Use the following command to clean up
docker RMI $(docker images – F “dangling = true” – Q)
docker does not have an automatic garbage collection mechanism, which may be improved in the future, but at present we can only clean it manually (just write a script)

Similar Posts: