ReynierPM
ReynierPM

Reputation: 18660

Can't remove image due to error: "Error response from daemon: reference does not exist"

I'm having a strange problem while trying to clear the images created by Docker. This is what I did:

Then this error: No such image: 2f21ea981017:latest comes up and I should ask, why? Where is such image? There is some kind of internal DB for Docker where it stores information?

After I run all the previous commands then I run the following and notice the output:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              14.04.5             b1719e1db756        3 days ago          187.9 MB

But then I tried to remove the images again by running

$ docker rmi b1719e1db756
Error response from daemon: reference does not exist

And I got the same error, what I am missing here? How I can fix this?

I should add that I've run also the commands from this post but without success.

Upvotes: 7

Views: 33986

Answers (2)

Bright Fan
Bright Fan

Reputation: 61

I have encountered this problem on docker-ce 17.06/fedora 26. I don't think you need to remove docker, but these commands will delete all your images. So save any images you really need, delete all, and restore your backup;

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

Upvotes: 6

ReynierPM
ReynierPM

Reputation: 18660

I will answer myself after some research and the great help from the people behind Docker at Github.

Summary: At first I install docker by running the following command:

$sudo dnf install docker -y

That installed docker from RedHat fork and therefore the version was: 1.10.3, then using this version I built the image that was causing problems until now. After build the image I remove the docker 1.10.3 version and switch to docker-engine which is the official and install 1.12.1.

The problem: I was trying to remove the image created under docker 1.10.3 but using docker 1.12.1 and from there is where the problem comes from.

The solution: remove docker-engine and install temporary docker in order to remove the images created under such version.

  • Remove docker-engine: dnf remove docker-engine
  • Install docker: dnf install docker
  • Remove the images: docker rmi -f $(docker images -q)
  • Remove the docker: dnf remove docker
  • Install docker-engine: dnf install docker-engine
  • Build the images from scratch

Note: for some reason after I follow every steps as shown above I run into the following issue:

$docker images
Error response from daemon: client is newer than server (client API version: 1.24, server API version: 1.22)

Doing a dnf autoremove && dnf clean all and restarting docker fix the issue.

Feel free to take a look here if you want more

Upvotes: 3

Related Questions