"Docker Images" Shows Image, "Docker Rmi" Says "No Such Image" or "Reference Does Not Exist"

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

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

docker rmi hash gives Error: No such image:

What will make it work will depend on what is actually causing the problem. But here are some possible solutions:

Solution 1: Restart the docker daemon:

# in case you are using Linux
sudo systemctl stop docker
sudo systemctl start docker

and then try to remove the images once again after that.

Solution 2: Try to remove the images as pointed out in this article

Solution 3: If nothing of that works, take a look at some answers replied on this other question. The accepted answer there has some side effects (read the comments related to it before doing that).

Docker Compose: No such image

The old cache caused this issue, I failed to run this command the first time and docker-compose already created images which I can't see from docker images.

Need to check from docker-compose ps, and remove all old images with this command docker-compose rm, then rebuild again.

Docker error cannot delete docker container, conflict: unable to remove repository reference

First, remove the container names

$ sudo docker rm backstabbing_ritchie

The result

$ sudo docker rm backstabbing_ritchie
backstabbing_ritchie

delete the second part, which is listed on the container to be deleted

$ sudo docker rm drunk_feynman 
drunk_feynman

Second, remove the container

$ sudo docker rmi training/webapp

The result

$ sudo docker rmi training/webapp  
Untagged: training/webapp:latest
Deleted: 54bb4e8718e8600d78a5d7c62208c2f13c8caf0e4fe73d2bc0e474e93659c0b5
Deleted: f74dd040041eb4c032d3025fe38ea85de8075992bdce6789b694a44b20feb8de
Deleted: 7cbae69141977b99c44dc6957b032ad50c1379124d62b7d7d05ab7329b42348e
Deleted: abb991a4ed5e4cde2d9964aec4cccbe0015ba9cc9838b696e7a32e1ddf4a49bd
Deleted: 1952e3bf3d7e8e6a9b1e23bd4142e3c42ff7f4b7925122189704323593fd54ac
Deleted: f95ebd363bf27a7546deced7a41a4099334e37a3d2901fa3817e62bb1ade183f
Deleted: 20dd0c75901396d41a7b64d551ff04952084cc3947e66c67bae35759c80da338
Deleted: 2505b734adda3720799dde5004302f5edb3f2a2ff71438f6488b530b728ba666
Deleted: 2ee0b8f351f753f78f1178000ae37616eb5bf241d4ef041b612d58e1fd2aefdc
Deleted: 2ce633e3e9c9bd9e8fe7ade5984d7656ec3fc3994f05a97d5490190ef95bce8d
Deleted: 98b15185dba7f85308eb0e21196956bba653cf142b36dc08059b3468a01bf35d
Deleted: 515565c29c940355ec886c992231c6019a6cffa17ff1d2abdfc844867c9080c5
Deleted: 2880a3395eded9b748c94d27767e1e202f8d7cb06f1e40e18d1b1c77687aef77

Check the continer

  $ sudo docker ps -as
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE
78479ffeba5c ubuntu "/bin/bash" 43 hours ago Exited (0) 43 hours ago sharp_wescoff 81 B (virtual 187.7 MB)

image is being used by stopped container

You can also use --force , -f Force removal of the image

If you use the -f flag and specify the image’s short or long ID, then
this command untags and removes all images that match the specified
ID.

  docker rmi -f <image_id> 

Note: this command removes images being used by containers.

Docker rmi unable to remove images

As the comments on your question indicate, you have figured out that you need to use:

  • docker rmi to remove images
  • docker rm to remove containers

for a bit more background: there is a difference between:

  1. A docker image,
  2. A running container based off that image and
  3. A stopped container based off that image

The stopped container is kept because running the container might have changed the file system in the container, you can then commit this stopped container to have a new image. (that's one way to create images, manually run the commands and commit the resulting container).

Creating images using docker build and Dockerfile, does the same thing, it runs the container executing the Dockerfile commands and commits the resulting images, only tagging the last image that was committed.



Related Topics



Leave a reply



Submit