docker删除镜像时报错:image is referenced in multiple repositories

蔚落 2022-12-28 14:02 358阅读 0赞
  1. [root@localhost ~]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. centos 7 8652b9f0cb4c 4 weeks ago 204MB
  4. centos 7.9.2009 8652b9f0cb4c 4 weeks ago 204MB

想删除这个centos镜像
不过在删除时失败
报错:同一个镜像在多个存储库中被引用

  1. [root@localhost ~]# docker rmi 8652b9f0cb4c
  2. Error response from daemon: conflict: unable to delete 8652b9f0cb4c (must be forced) -
  3. image is referenced in multiple repositories

解决办法

1.使用repository和tag的方法删除

  1. [root@localhost ~]# docker rmi centos:7.9.2009
  2. Untagged: centos:7.9.2009
  3. Untagged: centos@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
  4. Deleted: sha256:8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
  5. Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02
  6. [root@localhost ~]# docker images centos
  7. REPOSITORY TAG IMAGE ID CREATED SIZE

再次查看,两个镜像都被删除了

2.使用-f选项进行删除

在docker rmi参数中,有-f选项,强制删除镜像

  1. [root@localhost ~]# docker rmi -f 8652b9f0cb4c
  2. Untagged: centos:7
  3. Untagged: centos:7.9.2009
  4. Untagged: centos@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
  5. Deleted: sha256:8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf

再次查看,镜像没有了,删除成功

发表评论

表情:
评论列表 (有 0 条评论,358人围观)

还没有评论,来说两句吧...

相关阅读