Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Remove all containers

    $ docker rm $(docker ps -a -q)
    bb3927e956bf
    3e2eeb6287c4
    
  • Check if there is any container running or created after:

    $ docker ps -a
    CONTAINER ID    IMAGE    COMMAND    CREATED    STATUS    PORTS    NAMES
    
  • Remove all images: the first attempt failed because images were referenced

    $ docker rmi $(docker images -q)
    Error response from daemon: conflict: unable to delete 2f21ea981017 (must be forced) - image is referenced in one or more repositories
    Error response from daemon: conflict: unable to delete 2f21ea981017 (must be forced) - image is referenced in one or more repositories
    
  • Remove all images using -f option:

    $ docker rmi -f $(docker images -q)
    Untagged: dev-php55:latest
    Untagged: reynierpm/dev-php55:latest
    Deleted: sha256:2f21ea981017f65adcf0df3764756690adc35d80538bbb6dcada12990f589f37
    Deleted: sha256:7fbddc1aa50dca9bdf4f8c8033d20eca26ac00432f57333987c0eac3fe55fb08
    Deleted: sha256:15883aeb774feafa64328ea2e77ebbe17a91e79ca1cd8bb2eebca60802fb01f5
    Deleted: sha256:36ff96a995807763e302657eaeb671c000e58e3128a47f63bae543ba501387ed
    Deleted: sha256:053f436f01f809f60ecba9fb961dfb6404dce163f84fbd905eb47a6b436ba50d
    Deleted: sha256:b4525a37a105a199b7e7772de9e6ad86af645509c94c705bd13fbd422bf8f55d
    Deleted: sha256:228092e34fffbb9def7f883eceea9f37fce3750d7a7d5a7551ce009410567240
    Deleted: sha256:a17ed03e91cc4bef074258f731bba0945bcacc78c7ac9f00d88ca111125c94c0
    Deleted: sha256:6118ff18e2049d3e13a903c4163e4e4aceea9fdd30555bdd71a1e23e8d5aa022
    Deleted: sha256:b7347848822645efd3259a6c200a94c7bba15fc72b504c704e39f5db0cdca1a2
    Deleted: sha256:b23b831be841f1f3cececec3e52480723d8312b464d9a89957e867fa695a4eca
    Deleted: sha256:86c4c6d54d9dee52f8abe0ba8b3622b985bce68923dada61838b45860f000f44
    Deleted: sha256:f053241f28e7c62ac77b44ee2f69a7bd6d2bb2ccdd9f916e43b8af88f5865f90
    Deleted: sha256:3f36e15d9aac3c197472d66904fc59bd509ca36c8aa885165aadc6507f27126c
    Deleted: sha256:6586309b23369f2ccb067ca456ebacd1602787960215d7c2e898c28ae6a2e78d
    Deleted: sha256:43d7779d3bcd75a466df309735762f33552c2caf8f656ce1e26e1fd6b0324c49
    Deleted: sha256:9e060bbbad0c042fc45eb52d3e4c41bfd30fb620459f10c62cf7e483d514e1d8
    Deleted: sha256:9da9f4caedc27c128dc51d273f9d1411d6fce3f560c606fff0567d912d2d95e4
    Error response from daemon: No such image: 2f21ea981017:latest
    Error response from daemon: reference does not exist
    

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.

like image 765
ReynierPM Avatar asked Sep 23 '16 14:09

ReynierPM


1 Answers

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

like image 60
ReynierPM Avatar answered Oct 23 '22 04:10

ReynierPM