Home  >  Article  >  Operation and Maintenance  >  Why does docker use tags?

Why does docker use tags?

WBOY
WBOYOriginal
2022-08-15 18:19:572455browse

In docker, because tags can be used to mark local processes and classify them into a certain warehouse, the tag command needs to be used; the syntax of the tag command is "docker tag SOURCE_IMAGE[:TAG] original image TARGET_IMAGE[ :TAG] New Image".

Why does docker use tags?

The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.

Why does docker use tag

docker tag: Mark the local image and classify it into a certain warehouse.

Syntax

docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]

Example

Mark the image ubuntu:15.10 as a runoob/ubuntu:v3 image.

Why does docker use tags?

The example is as follows:

1. docker images view the image

docker images

Why does docker use tags?
2. Tag the docker.io/centos image. Before labeling, the label of docker.io/centos defaults to latest. If it is another version, please indicate it.
For example, tag the docker.io/centos image:

docker tag docker.io/centos docker.io/centos:v1

Why does docker use tags?
After the execution is completed, check the new image through docker images TAG: v1
Success!

3. By analogy, when you need to develop a second version, continue to tag: v2

docker tag docker.io/centos docker.io/centos:v2

Why does docker use tags?
4. If for some reason, when you want When you need to roll back the version, you can create a container by specifying the label's image:

Chestnut:

Start centos:v1 version:

docker run-itd docker.io/centos:v1

After execution, view through docker ps

Found that the container has been started! Why does docker use tags?

Recommended learning: "docker video tutorial"

The above is the detailed content of Why does docker use tags?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn