5
解决docker image has dependent child images 错误
source link: https://www.ishells.cn/archives/solve-docker-rm-image-error
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
问题描述:
在Docker中删除images有时会遇到类似的报错:
Error response from daemon: conflict: unable to delete 6ec9a5a0fc9f (cannot be forced) - image has dependent child images
这样的错误,原因是有另外的 image FROM 了这个 image,可以使用下面的命令列出所有在指定 image 之后创建的 image 的父 image
docker image inspect --format='{{.RepoTags}} {{.Id}} {{.Parent}}' $(docker image ls -q --filter since=xxxxxx) # 其中 xxxxxx 是报错 image 的 id,在文章开头的例子中就是 6ec9a5a0fc9f。从列表中查找到之后就可以核对并删除这些 image
查找出所有在指定 image 之后创建的 image 的父 image,删除关联的依赖镜像,关联的none镜像也会被删除
# 停止所有容器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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK