I am rather new to Docker, I have recently started running ubuntu container, and stopped it gracefully a few days later (I do not see it using "docker ps"). When I tried to remove ubuntu image using
docker rmi ubuntu
I got the following error:
Error response from daemon: conflict: unable to remove repository reference "ubuntu" (must force) - container 65c315b169b8 is using its referenced image 747cb2d 60bbe
Can I use "--force" to force a removal of the image,
docker rmi ubuntu --force
Or is there a graceful/safer way to do it?
As a result, the container continues to run fine as the layers are still there, they're simply untagged. You can docker rmi <ID> or docker images prune (without -a it will only delete "dangling" images, I. E. not including unused ones). Thus the answer is "yes, but it won't delete containers if that's what you're hoping for", but now you know why.
It may be exited rather than running, so you can do a docker ps -a | grep $image_id for a quick list of containers running that specific image id, but the preferred list would include any descendants: Then you'll be able to run your docker image rm (or docker rmi) command. Update: If you force remove an image, all docker does is untag it.
By default docker ps will only show running containers. You can show the stopped ones using docker ps --all. You can then remove the container first with docker rm <CONTAINER_ID> If you want to remove all of the containers, stopped or not, you can achieve this from a bash prompt with Show activity on this post.
By default docker ps
will only show running containers. You can show the stopped ones using docker ps --all
.
You can then remove the container first with docker rm <CONTAINER_ID>
If you want to remove all of the containers, stopped or not, you can achieve this from a bash prompt with
$ docker rm $(docker ps --all -q)
The -q switch returns only the IDs
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