image is being used by stopped container

Mehrdad Babaki picture Mehrdad Babaki · Jul 5, 2018 · Viewed 72.1k times · Source

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

Answer

Adiii picture Adiii · Jul 5, 2018

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>