Docker错误:image has dependent child images

problem

When deleting image in Docker, I sometimes encounter something like

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

The reason for this error is that another image FROM has this image. You can use the following command to list all the parent images of the image created after the specified image

docker image inspect --format='{
    
    {.RepoTags}} {
    
    {.Id}} {
    
    {.Parent}}' $(docker image ls -q --filter since=xxxxxx)

Where xxxxxx is the id of the error image, which is 6ec9a5a0fc9f in the example at the beginning of the article. After finding from the list, you can check and delete these images.

Other operations

# 停止所有容器~ docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker stop
# 删除所有容器~ docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker rm
# 删除所有none容器~ docker images|grep none|awk '{print $3 }'|xargs docker rmi

reference:

  • https://blog.csdn.net/renzhewudi77/article/details/82858280

Guess you like

Origin blog.csdn.net/zzq060143/article/details/106859617