docker的tag是做什么用的

docker中,tag是用于标记本地镜像,并且将其归入某一仓库的命令;该命令可以用于给镜像打标签,语法为“docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]”。

docker的tag是做什么用的

本教程操作环境:linux7.3系统、docker19.03版、Dell G3电脑。

docker的tag是做什么用的

docker tag : 标记本地镜像,将其归入某一仓库。

语法

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

实例

将镜像ubuntu:15.10标记为 runoob/ubuntu:v3 镜像。

root@runoob:~# docker tag ubuntu:15.10 runoob/ubuntu:v3
root@runoob:~# docker images   runoob/ubuntu:v3
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
runoob/ubuntu       v3                  4e3b13c8a266        3 months ago        136.3 MB

详解如下

通过ID tag镜像

下面是tag一个id为0e5574283393的本地镜像到“fedora”存储库,tag名称version1.0:

docker tag 0e5574283393 fedora/httpd:version1.0

通过名称tag镜像

使用名称“httpd” tag本地镜像到存储库”fedora”,且其tag名为version1.0

docker tag httpd fedora/httpd:version1.0

注意由于引用httpd的tag名称没有指定,默认引用httpd:latest。

通过名称和tag名称tag一个镜像

为名称为httpd和tag名称为test的本地镜像做标签,其存储库为fedora,标签名为version1.0.test。

docker tag httpd:test fedora/httpd:version1.0.test

tag一个镜像到私有的存储库

要推送一个镜像到一个私有的registry,而不是公共的docker registry,必须指定一个registry主机名和端口来tag此镜像。

docker tag 0e5574283393 myregistryhost:5000/fedora/httpd:version1.0

推荐学习:《docker视频教程》

以上就是docker的tag是做什么用的的详细内容,更多请关注https://www.sxiaw.com/其它相关文章!