Skip to content

Cannot delete Docker images

I got a wired issue that docker image cannot be deleted fully, even restart doesn’t help.

the docker version is 17.12

1
2
[root@guanvps ~]# docker --version
Docker version 17.12.1-ce, build 7390fc6
1
2
3
4
5
6
7
8
[root@guanvps ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              ae513a47849c        4 weeks ago         109MB
ubuntu              latest              452a96d81c30        5 weeks ago         79.6MB
[root@guanvps ~]# docker rmi ae5
Error: No such image: ae5
[root@guanvps ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

when pulling image again from Docker Hub and delete image, it prompts conflct error again.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
[root@guanvps ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
Digest: sha256:b1d09e9718890e6ebbbd2bc319ef1611559e30ce1b6f56b2e3b479d9da51dc35
Status: Downloaded newer image for nginx:latest
[root@guanvps ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              ae513a47849c        4 weeks ago         109MB
nginx               latest              ae513a47849c        4 weeks ago         109MB
ubuntu              latest              452a96d81c30        5 weeks ago         79.6MB
[root@guanvps ~]# docker rmi ae5
Error response from daemon: conflict: unable to delete ae513a47849c (must be forced) - image is referenced in multiple repositories
[root@guanvps ~]# docker rmi ae5 --force
Error: No such image: ae5
[root@guanvps ~]# docker rmi ae5
Error: No such image: ae5

this could be related to Docker image folder or another folder. so enter /var/lib/docker/images/

1
2
3
root@guanvps ~]# cd `find /var/lib/docker -path '*/imagedb/*tent/sha256'`
[root@guanvps sha256]# ls
452a96d81c30a1e426bc250428263ac9ca3f47c9bf086f876d11cb39cf57aeec  ae513a47849c895a155ddfb868d6ba247f60240ec8495482eca74c4a2c13a881

delete the folder starting with ae5*

1
2
3
4
[root@guanvps sha256]# rm -f ae5*
[root@guanvps sha256]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              452a96d81c30        5 weeks ago         79.6MB

Leave a Reply