Error:
想删除centos镜像,因为docker images 里面有两个centos,所以删除其中一个。
[root@jdcloud3 ~]# docker rmi centos:latest
Error response from daemon: conflict: unable to remove repository
reference "centos:latest" (must force)
- container b78aedf3926a is using its referenced image 0f3e07c0138f
Solution:
出现这个问题是因为多个容器占用同一个镜像的问题,请重复删除即可。
centos 这个镜像删不了 是它在多个容器里在跑 一 一 remove掉
然后回来再去删除容器依赖的原镜像
[root@jdcloud3 ~]# docker rm b78aedf3926a
b78aedf3926a
[root@jdcloud3 ~]# docker rmi centos:latest
Untagged: centos:latest
Untagged: centos@sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
Deleted: sha256:0f3e07c0138fbe05abcb7a9cc7d63d9bd4c980c3f61fea5efa32e7c4217ef4da
Deleted: sha256:9e607bb861a7d58bece26dd2c02874beedd6a097c1b6eca5255d5eb0d2236983
[root@jdcloud3 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zookeeper latest 611ffeaf5959 2 days ago 224MB
redis latest dcf9ec9265e0 11 days ago 98.2MB
python latest 0a3a95c81a2b 12 days ago 932MB
mysql latest d435eee2caa5 12 days ago 456MB
<none> <none> e9ee535ba1b1 2 weeks ago 491MB
docker latest 52f7c6fb16b9 2 weeks ago 216MB
centos centos7 5e35e350aded 3 weeks ago 203MB
openjdk 8-jdk-alpine a3562aa0b991 6 months ago 105MB
hello-world latest fce289e99eb9 11 months ago 1.84kB
[root@jdcloud3 ~]#
PS:
镜像和容器就像是面向对象程序设计中的类和实例一样,镜像是静态的定义,容器是镜像运行时的实体。
你想删除某个镜像但是有多个容器依赖于这个镜像在running。