Skip to content
Home » Solve Docker error: “unable to delete (must be forced) – image is referenced in multiple repositories”

Solve Docker error: “unable to delete (must be forced) – image is referenced in multiple repositories”

Tags:

I’ve had to brush up my Docker skills again due to some side projects I’m working on. So I ran into some basic issues I wanted to elaborate on. In this blog post: “image is referenced in multiple repositories.”

I had to remove a Docker image from my machine using the rmi command.

docker rmi <image_id>

To my surprise, I was unable to delete the image. The following error was thrown:

Error response from daemon: conflict: unable to delete <image ID> (must be forced) - image is referenced in multiple repositories

For example, this can happen when you have an image that is referenced by multiple tags or multiple names. In the following example, I created two mirrors of redis.

docker pull redis:latest
docker tag redis:latest redis:my_new_tag
docker tag redis:latest redis_mirror:latest

The result is:

When you try to remove the image by ID, Docker does not know which image (mirror) you are referring to. There are two ways one can tackle this.

Instead of trying to remove the image using its image id, you’ll have to remove all repositories individually, by referencing them with their name and tag. The last one can be removed by referring to the image ID.

docker rmi redis:my_new_tag
rocker rmi redis_mirror
docker rmi 881

But there is also a faster solution. You can force docker to remove an image. By using the -f flag and the image’s (short or long) ID, the image gets untagged and is removed. Like this:

docker rmi -f <image ID>

And that’s how it’s done.

Say thanks, ask questions or give feedback

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

6 thoughts on “Solve Docker error: “unable to delete (must be forced) – image is referenced in multiple repositories””

  1. Extremely helpful! I started playing with Docker almost a year ago before jumping into a new subject. I recently got back to my Docker study and wanted to start with a clean slate. But I was unable to remove several of the older images that were generated during my initial exploration. This concise post was helpful. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *