Docker implements re-tagging and deleting the image of the original tag

Docker implements re-tagging and deleting the image of the original tag

The docker image id is unique and can physically identify an image. There can be multiple repository: tags, but they will not be repeated and are also unique.

To re-tag, the syntax is:

docker tag imageId repository:newTag

For example, re-tag centos:7 as centos7:base

At this point, there are two images in the repository with the same image ID, but with an additional tag, which means an additional reference. Simply delete the unnecessary references. You must use the tag to delete. Deleting with the image id will physically delete the image, and the two references will be deleted at the same time.

Of course, you can also use this syntax when typing tags:

docker tag repository:tag repository:newTag

Supplementary knowledge: Docker encountered a problem: When there are multiple tags for the same image, the docker rmi image ID command cannot be deleted

Mirror List

Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
runoob/centos 6.7 4994f1f799c7 2 days ago 191MB
runoob/centos dev 4994f1f799c7 2 days ago 191MB
tomcat latest da0729cd9201 2 days ago 463MB

Deleting an image

Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker rmi 4994f1f799c7

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

Deletion method 1

docker rmi -f image ID

As shown below:

Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker rmi -f 4994f1f799c7
Untagged: runoob/centos:6.7
Deleted: sha256:4994f1f799c7c9241c23055ecc7335c074caaa96243dcc665d1c1836216c34f2
Deleted: sha256:6829bdaf30b11efab68c0ae473690ae1637830a560487ce07ad08988484c0987
Deleted: sha256:fd54ea270ce8e890023eaba2a72eff187d27f71f3ffea9e11e9684de8ac9606a
Deleted: sha256:ece17abd46a222b2fa35f1e18a981092605453c258dceca6919e3572ab4f1fbf
Deleted: sha256:b59b8f6f9d682eeb94a3628fded0325e9d43664fdd26651971a6fc4bd34bc3ca
Deleted: sha256:71c39bd52e1858772c19aac2b18203dca9a02f6a07a4cef54099ecd14734da83
Deleted: sha256:6ff1dc40fd96eebca0785a047794a83f3c954e4949c350fbd0661ed0f7ed8c96
Deleted: sha256:19efa1023a08e6d4014cea1821fe9f3b169eed3c11397460fb19db1d22b69fb2
Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest da0729cd9201 2 days ago 463MB

docker rmi : Delete one or more local images.

grammar

docker rmi [OPTIONS] IMAGE [IMAGE…]

OPTIONS description:

-f : force deletion;

–no-prune: Do not remove the process image of this image, it is removed by default;

Deletion method 2

docker rmi repository:tag

As shown below:

Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker rmi runoob/centos:dev
Untagged: runoob/centos:dev
Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
runoob/centos 6.7 4994f1f799c7 2 days ago 191MB
tomcat latest da0729cd9201 2 days ago 463MB

Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker rmi runoob/centos:6.7
Untagged: runoob/centos:6.7
Cappuccinooos-MacBook-Pro:.docker Cappuccinooo$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest da0729cd9201 2 days ago 463MB

The above article about Docker's implementation of re-tagging and deleting the original tag image is all I have to share with you. I hope it can give you a reference, and 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
  • Solve the problem that the repository and tag names are both none after Docker loads a new image
  • Deleting two images with the same id in docker
  • Docker image import, export, backup and migration operations
  • Docker image creation Dockerfile and commit operations
  • Docker pull image and tag operation pull | tag

<<:  MYSQL string forced conversion method example

>>:  ul list tag design web page multi-column layout

Recommend

Summary of the differences and usage of plugins and components in Vue

The operating environment of this tutorial: Windo...

How to view nginx configuration file path and resource file path

View the nginx configuration file path Through ng...

HTML set as homepage and add to favorites_Powernode Java Academy

How to implement the "Set as homepage" ...

How to view and optimize MySql indexes

MySQL supports hash and btree indexes. InnoDB and...

HTML table tag tutorial (3): width and height attributes WIDTH, HEIGHT

By default, the width and height of the table are...

MySql 8.0.11 installation and configuration tutorial

Official website address: https://dev.mysql.com/d...

Implementation steps for setting up the React+Ant Design development environment

Basics 1. Use scaffolding to create a project and...

MySQL implementation of lastInfdexOf function example

Sometimes MySQL needs to use a function similar t...

Examples of correct use of interface and type methods in TypeScript

Table of contents Preface interface type Appendix...

An example of elegantly writing status labels in Vue background

Table of contents Preface optimization Extract va...

Implementation of mysql data type conversion

1. Problem There is a table as shown below, we ne...

Docker memory monitoring and stress testing methods

The Docker container that has been running shows ...

Example code of html formatting json

Without further ado, I will post the code for you...

Detailed explanation of Linux file permissions and group modification commands

In Linux, everything is a file (directories are a...