0
点赞
收藏
分享

微信扫一扫

8-docker删除两个相同IMAGE ID镜像报错的处理方案

1.问题描述

docker在删除两个相同IMAGE ID镜像(E.g:docker rmi 605c77e624dd)时,会有如下报错:

Error response from daemon: conflict: unable to delete 605c77e624dd (must be forced) - image is referenced in multiple repositories

[root@centos79 ~]# docker images | grep nginx
nginx-test                      1.0           605c77e624dd   23 months ago   141MB
nginx                           latest        605c77e624dd   23 months ago   141MB
[root@centos79 ~]# docker rmi 605c77e624dd
Error response from daemon: conflict: unable to delete 605c77e624dd (must be forced) - image is referenced in multiple repositories
[root@centos79 ~]#

2.解决方案

2.1.方案一:

使用repository加tag的方式进行image的删除。

命令:

docker rmi nginx-test:1.0 

[root@centos79 ~]# docker images | grep nginx
nginx-test                      1.0           605c77e624dd   23 months ago   141MB
nginx                           latest        605c77e624dd   23 months ago   141MB
[root@centos79 ~]# docker rmi nginx-test:1.0 
Untagged: nginx-test:1.0
[root@centos79 ~]# docker images | grep nginx
nginx                           latest        605c77e624dd   23 months ago   141MB
[root@centos79 ~]#

2.2.方案二:

使用docker rmi -f 的方式进行镜像的删除,不过该方式会把两个相同IMAGE ID镜像全部删除。

命令:

docker rmi -f IMAGE_ID

-f:--force Force removal of the image

[root@centos79 ~]# docker images | grep nginx
nginx-test                      1.0           605c77e624dd   23 months ago   141MB
nginx                           latest        605c77e624dd   23 months ago   141MB
[root@centos79 ~]# docker rmi -f 605c77e624dd
Untagged: nginx-test:1.0
Untagged: nginx:latest
Untagged: nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Deleted: sha256:605c77e624ddb75e6110f997c58876baa13f8754486b461117934b24a9dc3a85
[root@centos79 ~]# docker images | grep nginx
[root@centos79 ~]#

举报

相关推荐

0 条评论