Deleting two images with the same id in docker

Deleting two images with the same id in docker

When I created a Docker container today, I accidentally entered the wrong name for the image. As a result, after the container was successfully created, two images with the same ID appeared:

Execution failed when deleting using docker rmi e4a35914679d:

Error response from daemon: conflict: unable to delete e4a35914679d (must be forced) - image is referenced in one or more repositories

The prompt should be that there are two local files for this id and they cannot be deleted using the id.

So I want to delete all images docker rmi $(docker images -q), and the following error occurs

Error response from daemon: conflict: unable to delete e4a35914679d (must be forced) - image is referenced in one or more repositories

Later, I saw on Stack Overflow that I used repository and tag to do this, so I executed docker rmi docker.io/redis:3.2

When querying again, there is only one image left, so delete it.

So, you can use repository:tag combination to delete a specific image.

Additional knowledge: Docker deletes images with blank TAG and REPOSITORY

I learned docker initially and found a problem. After misoperation. A blank image with only IMAGE ID will be left.

How to delete it, it took several attempts before I succeeded.

When you want to delete the mirror with blank TAG and blank REPOSITORY, list the current mirrors

[root@iZ25kr7psegZ ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
azkaban_centos latest 8993c0c20f01 24 hours ago 244MB
<none> <none> d2dcb7c1f1ce 2 days ago 1.08GB
mysql latest 990386cbd5c0 7 days ago 443MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB

Execute the delete statement docker rmi IMAGE ID

[root@iZ25kr7psegZ ~]# docker rmi d2dcb7c1f1ce

Error response from daemon: conflict: unable to delete d2dcb7c1f1ce (must be forced) - image is being used by stopped container cde37d151fdf

This prompts you to stop the container that the image depends on

[root@iZ25kr7psegZ ~]# docker stop cde37d151fdf

cde37d151fdf

Then delete the container.

[root@iZ25kr7psegZ ~]# docker rm cde37d151fdf

cde37d151fdf

Then you can delete this blank image.

[root@iZ25kr7psegZ ~]# docker rmi d2dcb7c1f1ce
Deleted: sha256:d2dcb7c1f1ce916ea67a0a6c63cda40c62fa8dbc985845e64f3fafe9a37664f1
Deleted: sha256:86ad6d366bb4d0c9e4b176bc220ff8d421902e2bcb197c7c017f8da854c3c72d
Deleted: sha256:128e444c34b373f5e553883c65f676efdb2be22684bcbcf141fb724a7b3de316
Deleted: sha256:15d26edbae6fafd6acad6e3308445846202230b66c6199cb236268f932b59ce8

Query the mirror list again

[root@iZ25kr7psegZ ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
azkaban_centos latest 8993c0c20f01 24 hours ago 244MB
<none> <none> adbcb407e207 2 days ago 571MB
mysql latest 990386cbd5c0 7 days ago 443MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB

It was found that the size was reduced from 1.08G to 571M. This indicates that there is another container storing this image. Think of it like a Russian nesting doll. It needs to be deleted layer by layer. It must be because of too many docker commit operations.

During repeated operations, it was found that sometimes one image corresponds to different containers.

A stop and rm operation is performed for each container ID prompted. It should be that the image is loaded repeatedly due to too frequent startup times. The final result is of course a clean deletion.

[root@iZ25kr7psegZ ~]# docker rmi cb9f332b969f
Deleted: sha256:cb9f332b969ff425ef7bf781a1d7dff720dfa32a6e77a20347552b76f6b763eb
Deleted: sha256:2a9ae33d11aadc05d24b58f67c6eb577c64eceff0528d06207e49963257e5f24
[root@iZ25kr7psegZ ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
azkaban_centos latest 8993c0c20f01 24 hours ago 244MB
mysql latest 990386cbd5c0 7 days ago 443MB
centos latest 9f38484d220f 2 months ago 202MB
hello-world latest fce289e99eb9 4 months ago 1.84kB

The above operation of deleting two images with the same ID under Docker is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Solve the problem that docker run or docker restart will automatically exit when starting the image
  • Use nexus as a private library to proxy docker to upload and download images
  • Docker starts the elasticsearch image and solves the error after mounting the directory
  • Docker implements re-tagging and deleting the image of the original tag
  • Solve the problem that the repository and tag names are both none after Docker loads a new image
  • Docker image import, export, backup and migration operations
  • Docker image creation Dockerfile and commit operations
  • Docker pull image and tag operation pull | tag

<<:  Table Tag (table) In-depth

>>:  JavaScript to achieve product magnifying glass effect

Recommend

Detailed analysis of the difference between Ref and Reactive in Vue3.0

Table of contents Ref and Reactive Ref Reactive T...

iframe adaptive size implementation code

Page domain relationship: The main page a.html bel...

Linux kernel device driver address mapping notes

#include <asm/io.h> #define ioremap(cookie,...

How to extract string elements from non-fixed positions in MySQL

Preface Note: The test database version is MySQL ...

MySQL 5.7.31 64-bit free installation version tutorial diagram

1. Download Download address: https://dev.mysql.c...

The correct way to migrate MySQL data to Oracle

There is a table student in the mysql database, i...

Three ways to forward linux ssh port

ssh is one of the two command line tools I use mo...

Page Speed ​​Optimization at a Glance

I believe that the Internet has become an increas...

Linux swap partition (detailed explanation)

Table of contents linux 1. What is SWAP 2. What d...

Detailed explanation of Vue's simple store

The simplest application of store in Vue is globa...

Basic HTML directory problem (difference between relative path and absolute path)

Relative path - a directory path established based...

Several common methods of CSS equal height layout

Equal height layout Refers to the layout of child...

Useful codes for web page creation

<br />How can I remove the scroll bar on the...

Specific use of MySQL window functions

Table of contents 1. What is a window function? 1...