Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker rmi - Is it okay to use --force?

Tags:

docker

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?

like image 583
Uri Lukach Avatar asked Oct 30 '17 09:10

Uri Lukach


People also ask

Is it possible to prune a docker container without deleting 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.

How to remove an image from a docker container?

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.

How to show all containers that have been stopped in Docker?

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.


1 Answers

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

like image 124
Spangen Avatar answered Sep 21 '22 13:09

Spangen