'Getting "conflict: unable to remove repository reference"
I am trying to delete a test image:
docker image rm test-image
but I'm getting
Error response from daemon: conflict: unable to remove repository reference "test-image" (must force) - container 4ca6d09c1103 is using its referenced image 133c9587889f
However, this container does not exist:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fff756b1399a rocker/shiny "/usr/bin/shiny-se..." 6 months ago Up 12 days 0.0.0.0:3838->3838/tcp shinyServerBdl2
So: What is this about?
I've called
docker build . -t test-image
docker run -it test-image
to create the image from a Dockerfile
but why can't I delete the image here? I also tried
docker rmi test-image
without success.
Solution 1:[1]
Make sure that a container does not exist that is using the image. The container can be stopped and thus won't show when you run docker ps
. You can do docker ps --all
to view all runninn and stopped container.
In short, running the following should remove the image:
docker container rm 4ca6d09c1103
docker image rm test-image
Solution 2:[2]
If you are in dev environment, and if you want to remove all of images, you can use this:
$ docker rm $(docker ps -a -q) -f
But don't do this in prod!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | yamenk |
Solution 2 |