解决Error response from daemon: conflict: unable to delete 7597f617968f (must be forced) - image is be

在删除REPOSITORY为none的docker镜像时,报如下Error错误:

[root@VM-0-16-centos ~]# docker images | grep none | awk '{print $3}' | xargs docker rmi
Error response from daemon: conflict: unable to delete 7597f617968f (must be forced) - image is being used by stopped container cfc1f6709c6a

原因是这个镜像已经作为容器启动运行过,需要先删除容器,再删除镜像。
使用docker ps -a查看所有的容器:

[root@VM-0-16-centos ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                    PORTS                                   NAMES
cd50469474fa   nginx          "/docker-entrypoint.…"   11 minutes ago   Up 11 minutes             0.0.0.0:9001->80/tcp, :::9001->80/tcp   musing_lovelace
a230d1c6d569   7597f617968f   "/bin/sh -c 'pip ins…"   47 hours ago     Exited (1) 47 hours ago                                           naughty_chandrasekhar
cfc1f6709c6a   7597f617968f   "/bin/sh -c 'pip ins…"   47 hours ago     Exited (1) 47 hours ago                                           reverent_tesla

删除container_id为cfc1f6709c6a和a230d1c6d569的容器

[root@VM-0-16-centos ~]# docker rm cfc1f6709c6a
cfc1f6709c6a
[root@VM-0-16-centos ~]# docker rm a230d1c6d569
a230d1c6d569

再删除镜像可成功删除:

[root@VM-0-16-centos ~]# docker images | grep none | awk '{print $3}' | xargs docker rmi
Deleted: sha256:7597f617968f1cd6c1bbd9750e6ad592d426a97f0c21c193b12b096cbbd9028c
Deleted: sha256:97248e1cc643aa2ef8a15ed69c8be93119c6de48dfc5b1e1fcaa1d08730f56dd
Deleted: sha256:a0d59b817e94bec945457b77bd8a92a6833f982f6af0e621f6c66225850b70f7
Deleted: sha256:feca55425f190f1f25e8782ba4799e1bf9170fe132066577208238d5f3958208

查看所有的镜像,发现REPOSITORY为none的镜像已经全部删除掉:

[root@VM-0-16-centos ~]# docker images
REPOSITORY   TAG        IMAGE ID       CREATED         SIZE
nginx        latest     62d49f9bab67   5 months ago    133MB
python       2.7-slim   eeb27ee6b893   17 months ago   148MB
java         8          d23bdf5b1b1b   4 years ago     643MB

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值