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.
Use the docker container prune command to remove all stopped containers, or refer to the docker system prune command to remove unused containers in addition to other Docker resources, such as (unused) images and networks.
It created the three containers, and you can see them running with docker ps -a. Stopping them is just as easy. Simply run docker-compose down in the same directory.
The docker system prune command is a shortcut that prunes images, containers, and networks. Volumes are not pruned by default, and you must specify the --volumes flag for docker system prune to prune volumes. By default, you are prompted to continue. To bypass the prompt, use the -f or --force flag.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With