[报错](Error response from daemon: conflict: unable to delete 13f1d974653f (cannot be forced) - image has dependent child images)
报错的意思是需要先删除容器,再删除镜像
- 查看所有镜像
[root@docker-1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 252b7413377f About an hour ago 210MB
nginx latest 4cdc5dd7eaad 12 days ago 133MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos <none> 300e315adb2f 7 months ago 209MB
删除最后一个,但是删除报错
- 删除镜像报错
docker rmi -f 13f1d974653f
Error response from daemon: conflict: unable to delete 13f1d974653f (cannot be forced) - image has dependent child images
- 查看容器,我已经将所有的容器都删除了,如下结果
[root@docker-1 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 继续删除镜像
[root@docker-1 ~]# docker rmi 300e315adb2f
Error response from daemon: conflict: unable to delete 300e315adb2f (cannot be forced) - image has dependent child images
还是会报错,我又换了一个方法
- 删除镜像,并加上版本
[root@docker-1 ~]# docker rmi centos:<none>
-bash: 未预期的符号 `newline' 附近有语法错误
我发现,版本出现none后无法删除
接下来重要的
- 将需要删除的镜像的版本号进行重命名
[root@docker-1 ~]# docker tag 300e315adb2f centos:v1
- 然后运行删除,成功了
[root@docker-1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 252b7413377f About an hour ago 210MB
nginx latest 4cdc5dd7eaad 12 days ago 133MB
hello-world latest d1165f221234 4 months ago 13.3kB
centos v1 300e315adb2f 7 months ago 209MB
[root@docker-1 ~]# docker rmi centos:v1
Untagged: centos:v1
Untagged: centos@sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
以上是我遇到问题,并解决的方法,希望可以帮到你们。