docker tag詳解


docker tag 用於給鏡像打標簽,語法如下:

docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

① 比如我現在有一個 centos 鏡像:

[root@localhost ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              1e1148e4cc2c        2 weeks ago         202MB

② 我對 centos 進行開發,開發了第一個版本,我就可以對這個版本打標簽,打完標簽后會生成新的鏡像:

[root@localhost ~]$ docker tag centos centos:v1
[root@localhost ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              1e1148e4cc2c        2 weeks ago         202MB
centos              v1                  1e1148e4cc2c        2 weeks ago         202MB

③ 我繼續對 centos 進行開發,開發了第二個版本,繼續打標簽:

[root@localhost ~]$ docker tag centos centos:v2
[root@localhost ~]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              1e1148e4cc2c        2 weeks ago         202MB
centos              v1                  1e1148e4cc2c        2 weeks ago         202MB
centos              v2                  1e1148e4cc2c        2 weeks ago         202MB

④ 以此類推,每開發一個版本打一個標簽,如果以后我想回滾版本,就可以使用指定標簽的鏡像來創建容器:

[root@localhost ~]$ docker run -itd centos:v1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM