Home > Article > Operation and Maintenance > Why does docker use tags?
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".
The operating environment of this tutorial: linux7.3 system, docker version 19.03, Dell G3 computer.
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.
The example is as follows:
1. docker images view the image
docker images
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
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
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!
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!