Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"docker images" shows image, "docker rmi" says "no such image" or "reference does not exist"

Tags:

linux

docker

In some reasons I can't delete docker image. Here is output

OS version:

Linux localhost.localdomain 4.12.13-300.fc26.x86_64 #1 SMP Thu Sep 14 16:00:38 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

docker version

Client:
 Version:      17.06.2-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 20:05:40 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.2-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   cec0b72
 Built:        Tue Sep  5 20:06:58 2017
 OS/Arch:      linux/amd64
 Experimental: false`

I have no any container:

$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED                 STATUS              PORTS               NAMES

and two images that I want to delete:

$ docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
gcc                 7.1.0               855a4f4d1cd9        2 months ago        1.64GB
hello-world         latest              1815c82652c0        3 months ago        1.84kB

My attempts:

$ docker rmi -f gcc:7.1.0
Error response from daemon: No such image: gcc:7.1.0

$ docker rmi -f 855a4f4d1cd9
Error response from daemon: reference does not exist

$ docker rmi -f hello-world:latest 
Error response from daemon: No such image: hello-world:latest

$ docker rmi -f 1815c82652c0
Error response from daemon: reference does not exist44

What the reason could be and how can I delete those images?

like image 291
RidgeA Avatar asked Sep 23 '17 16:09

RidgeA


3 Answers

This means that your docker state is corrupted and you need clear the complete state

sudo service docker stop
sudo rm -rf /var/lib/docker
sudo service docker start

This will start docker fresh without any existing data. Try pulling deleting the image after this and see if all works. If it doesn't then there is some issue that needs to be looked into

like image 92
Tarun Lalwani Avatar answered Oct 17 '22 10:10

Tarun Lalwani


Try first a docker image prune or even docker image prune -a, to remove any image unused/not associated to at least one container.

If those are still listed, restart your docker daemon.

like image 40
VonC Avatar answered Oct 17 '22 10:10

VonC


To avoid deleting all of your docker data and starting from scratch, you can also attempt to manually clean up the broken references by matching the bad image references to the files in /var/lib/docker/image/devicemapper/imagedb/content/sha256. Once the corresponding file is deleted there, it will no longer show up in subsequent calls to docker images, and no daemon restarts are required.

like image 9
tzrlk Avatar answered Oct 17 '22 11:10

tzrlk