How to Solve Error Message : Error response from daemon: conflict: unable to remove repository reference “image-name” (must force)

Posted on

Introduction

This article title is quite long. But it is actually to inform completely the error message occurs open removing a docker image. This article has a specific subject to remove a docker image. It is removing the docker image which is failing only by using the normal command. That normal command itself exist in this link as an additional reference. It is an article with the title of ‘How to Remove Docker Images in the Local Machine’. So, the normal command is for removing the docker image using ‘docker rmi image_name’. But apparently, the execution of that command failed. The following is an example of that command execution which ends in failure :

latest              fce289e99eb9        8 months ago        1.84kB
root@hostname ~# docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container ffc2fb7d058e is using its referenced image fce289e99eb9
root@hostname ~#

It appears the image is still exist after executing the above command for removing the docker image. The following is an attempt to list again the available docker image in the local machine just to prove that the docker image is still exist :

root@hostname ~# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
centos-nginx_web              latest              36c49ff2d3bc        2 days ago          457MB
apache_image                  latest              2051d26d51fa        2 days ago          1.61GB
192.168.84.238:5000/busybox   latest              19485c79a9bb        2 weeks ago         1.22MB
php                           apache              aa4bdc74350b        2 weeks ago         414MB
php                           7.1-apache          1b3f4ce0de58        4 weeks ago         405MB
centos                        7                   67fa590cfc1c        4 weeks ago         202MB
centos                        latest              67fa590cfc1c        4 weeks ago         202MB
ubuntu                        latest              a2a15febcdf3        4 weeks ago         64.2MB
tomcat                        latest              6e30b06a90d3        4 weeks ago         506MB
mysql                         5.7                 e1e1680ac726        5 weeks ago         373MB
mysql                         latest              62a9f311b99c        5 weeks ago         445MB
mysql/mysql-cluster           latest              67fd04af4b8e        8 weeks ago         338MB
mysql/mysql-server            5.7                 d1469951af27        8 weeks ago         262MB
tensorflow/tensorflow         latest              7f03c4ff368a        3 months ago        1.17GB
centos                                      9f38484d220f        6 months ago        202MB
registry                      2                   f32a97de94e1        6 months ago        25.8MB
hello-world                   latest              fce289e99eb9        8 months ago        1.84kB
root@hostname ~# 

Completely remove docker image by force

So, in order to remove it completely and successfully, it is necessary to modify the command. Apparently, there is an additional parameter to the command for removing it by force. That argument is the ‘-force’ or ‘-f’ where it follows the actual command. The following is an example of the execution :

root@hostname ~# docker rmi -f hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd
Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
root@hostname ~# 

Leave a Reply