Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image is being used by stopped container

I am trying to delete a docker container by this command:

docker rmi <Image-Id> 

Obviously, I have replaced the Image-Id by the Id I get using:

docker images 

But I see the error below:

Error response from daemon: conflict: unable to delete <Image-ID> (must be forced) - image is being used by stopped container xxxxxxxxxxx 
like image 707
Nick Mehrdad Babaki Avatar asked Jul 05 '18 10:07

Nick Mehrdad Babaki


2 Answers

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.

like image 106
Adiii Avatar answered Dec 06 '22 09:12

Adiii


You need to delete the stopped container with docker rm, and then you can delete the image it uses with docker rmi.

like image 40
David Maze Avatar answered Dec 06 '22 07:12

David Maze