3

While setting up a new build machine (CentOS 7, Docker CE 17.12.0-ce), I did a simple test:

docker run -it --rm ubuntu bash

Which worked fine, but now I can't remove the Ubuntu image.

[build ~]$ docker image rm ubuntu
Error: No such image: ubuntu
[build ~]$ docker image rm ubuntu:latest
Error: No such image: ubuntu:latest
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        24 hours ago        112MB
[build ~]$ docker rmi 0458a4468cbc
Error: No such image: 0458a4468cbc

It's not being used by any containers (not that that's the error anyway):

[build ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[build ~]$

I even tried the nuke-from-orbit approach:

[build ~]$ docker rmi $(docker images -q)
Error: No such image: 0458a4468cbc

And restarting the docker daemon:

[build ~]$ sudo systemctl restart docker
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        24 hours ago        112MB
[build ~]$ docker rmi 0458a4468cbc
Error: No such image: 0458a4468cbc

What gives? Not that it really matters that the ubuntu image is there, I just don't understand why I can't clean it up.

Update

I tried pulling the image again, and, well:

docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
Digest: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
Status: Downloaded newer image for ubuntu:latest
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        25 hours ago        112MB
ubuntu              latest              0458a4468cbc        25 hours ago        112MB
[build ~]$ docker image rm ubuntu
Untagged: ubuntu:latest
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        25 hours ago        112MB
[build ~]$

Update 2

Tried the same basic steps with a brand new CentOS 7 1708 install and had no problems at all, so safe to say this is just a weird one-off corruption of something on this machine.

Question still is, how do I clean it up? Is there something on the filesystem I can just rm -rf and let docker start fresh?

4
  • have you tried docker images instead of docker image ls, I don't think there would be a difference though. Commented Jan 26, 2018 at 18:36
  • This looks like one to report as an issue. What storage driver are you using? docker info -f '{{ .Driver }}' Have you tried pulling the ubuntu image again? Commented Jan 26, 2018 at 18:50
  • Driver is devicemapper. Running docker images shows the same as docker image ls. Commented Jan 26, 2018 at 19:06
  • My driver is overlay2, but with the same problem. Commented Jan 4, 2022 at 14:45

4 Answers 4

12

While setting up this system I had originally installed an old version of docker available from the standard CentOS repositories (yum install centos) instead of adding the docker repositories and installing docker-ce. Even though I'm on the latest version now, the old one must have introduced some bad data in /var/lib/docker before I upgraded. In the end I just deleted all the local image and container data and started over:

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

Everything is working normally now.

Sign up to request clarification or add additional context in comments.

1 Comment

got exactly the same here, and your big gun approach fixed as well
3

I encountered similar thing, when I used rm -f, it was not working (could not delete)

docker rm -f <ImageId> 

I restarted Docker Engine and I used the following command, it works.

docker image prune -f -a

1 Comment

This left a bunch of images listed that still report "No such image"
0

You can try selecting the version of the operating system you want to delete, example:

docker image rm -f ubuntu:18.04

Comments

-2

maybe you can use docker image rm -f <ID_IMAGE>

1 Comment

What is new in this answer what the other answers didn't covered already?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.