一、問題:在測試docker安裝的prometheus系統時,由於異常操作,使用docker image ls出現了兩條一模一樣的條目,如下:
[root@ELK prometheus]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
prom/prometheus latest de242295e225 10 days ago 140MB
prom/prometheus latest de242295e225 10 days ago 140MB
可以看到,兩個條目一模一樣,不僅名稱相同,id相同,而且tag也相同。因此無法使用帶tag刪除的方法。
二、處理辦法
1、使用docker rmi de242295e225命令和docker rmi -f de242295e225命令都無法刪除。
考慮直接刪除image的存儲標識。
2、進入image所在目錄並查看image:
[root@ELK sha256]# cd /var/lib/docker/image/overlay2/imagedb/content/sha256
[root@ELK sha256]# ll
總用量 8
-rw-------. 1 root root 6667 5月 18 08:13 de242295e2257c37c8cadfd962369228f8f10b2d48a44259b65fef44ad4f6490
3、刪除image
[root@ELK sha256]# rm -rf de242295e2257c37c8cadfd962369228f8f10b2d48a44259b65fef44ad4f6490
4、重啟docker
[root@ELK sha256]# systemctl restart docker.service
5、重新pull所需要的prometheus鏡像image
[root@ELK prometheus]# docker pull prom/prometheus
6、重新運行prometheus:
[root@ELK prometheus]# docker run -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml -v $PWD/prometheus-data:/prometheus --name prometheus prom/prometheus