解决Error response from daemon: conflict: unable to delete bf6a13bd36ca (must be forced)
作者:互联网
在删除REPOSITORY为none的docker镜像时,报如下Error错误:
[root@dms-npm smart]# docker images|grep none|awk '{print $3 }'|xargs docker rmi
Error response from daemon: conflict: unable to delete bf6a13bd36ca (must be forced) - image is being used by stopped container 83ef6f249283
Error response from daemon: conflict: unable to delete c708b5be204f (must be forced) - image is being used by stopped container 6f753e89c2d8
原因是这个镜像已经作为容器启动运行过,需要先删除容器,再删除镜像。
使用docker ps -a查看所有的容器
[root@dms-npm smart]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5f0a8ef6f85f vue-demo:1.0 "nginx -g 'daemon of…" 14 hours ago Exited (0) 14 hours ago peaceful_einstein
fa3001859e72 vue-demo:1.0 "bash" 14 hours ago Exited (0) 14 hours ago jolly_roentgen
83ef6f249283 bf6a13bd36ca "bash" 14 hours ago Exited (0) 14 hours ago competent_yalow
2069ec23151c bf6a13bd36ca "nginx -g 'daemon of…" 14 hours ago Exited (0) 14 hours ago clever_lumiere
6f753e89c2d8 c708b5be204f "nginx -g 'daemon of…" 16 hours ago Exited (0) 15 hours ago condescending_keldysh
8f00915dad02 nginx:latest "bash" 16 hours ago Up 16 hours 80/tcp loving_jang
8c52ca94d8df docker-registry:5000/nginx:v1 "nginx -g 'daemon of…" 11 days ago Exited (0) 4 days ago nginx-web
删除container_id为 83ef6f249283和6f753e89c2d8的容器
[root@dms-npm smart]# docker rm 83ef6f249283
83ef6f249283
[root@dms-npm smart]# docker rm 6f753e89c2d8
6f753e89c2d8
再删除镜像可成功删除
[root@dms-npm smart]# docker images | grep none | awk '{FS=" "} {print $3}'| xargs -n 1 docker rmi $1
Deleted: sha256:bf6a13bd36ca6362ee8d9b1ed4e68f554ca4702aab75d7e8e5beaf7a4f9a9fdd
Deleted: sha256:f62fe61feca61d1711c134058ae72474ceb16892a97001abfd4715d2df5e4844
Deleted: sha256:c708b5be204fd3453e0b2bb2f60664e190a0537f9ff90b5ae009f83b24d4c4ff
Deleted: sha256:b96d792ad87b1df93d019d9334abfe6016546c78c632f78831ec4693c17bf216
查看所有的镜像,发现REPOSITORY为none的镜像已经全部删除掉
[root@dms-npm smart]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-registry:5000/vue-demo 1.0 af6ea583294b 14 hours ago 133MB
vue-demo 1.0 af6ea583294b 14 hours ago 133MB
nginx latest 9beeba249f3e 4 days ago 127MB
docker-registry:5000/nginx v1 5a9061639d0a 7 months ago 126MB
docker-registry:5000/grafana v1 2017e5eb53fa 8 months ago 261MB
强制删除镜像,加上-f参数即可
[root@dms-npm smart]# docker rmi -f af6ea583294b
Untagged: docker-registry:5000/vue-demo:1.0
Untagged: docker-registry:5000/vue-demo@sha256:c124e388f431e15d0f7d3bded9462a0c33a4a5c4b5f51fa741c7a3dd4aa2b0ff
Untagged: vue-demo:1.0
Deleted: sha256:af6ea583294b9df8395602af2595cc7d9abeada812b5a71f0b3cfdb97f6520dc
Deleted: sha256:3eab25c8f78133a1116a725f4fc295202da6d9e1551bbdb9102689877b8bb802
标签:ago,forced,daemon,14,bf6a13bd36ca,hours,nginx,docker,sha256 来源: https://blog.csdn.net/BUG_88/article/details/106231881