docker之企業級鏡像倉庫Harbor

Harbor概述

Habor是由VMWare公司開源的容器鏡像倉庫。事實上,Habor是在Docker Registry上進行了相應的
企業級擴展,從而獲得了更加廣泛的應用,這些新的企業級特性包括:管理用戶界面,基於角色的訪
問控制 ,AD/LDAP集成以及審計日誌等,足以滿足基本企業需求。
官方地址:https://vmware.github.io/harbor/cn/

Harbor部署

Harbor安裝有3種方式:

• 在線安裝:從Docker Hub下載Harbor相關鏡像,因此安裝軟件包非常小
• 離線安裝:安裝包包含部署的相關鏡像,因此安裝包比較大
• OVA安裝程序:當用戶具有vCenter環境時,使用此安裝程序,在部署OVA後啓動Harbor

Harbor部署

包路徑: 鏈接:https://pan.baidu.com/s/1QhCjEAoEepqELhm9IvMOTA 

有了harbor就不需要連外網下載鏡像了。harbor一般部署在宿主機上。
我們將harbor的包上傳到主機上,解壓,配置。需要修改一下訪問地址,我們這裏配置成本機ip,修改一下密碼,默認登錄密碼Harbor12345 。

[root@mcwk8s01 ~]# ls
anaconda-ks.cfg  harbor-offline-installer-v1.6.1.tgz  keepalived.conf  nginx.sh
[root@mcwk8s01 ~]# tar xf harbor-offline-installer-v1.6.1.tgz 
[root@mcwk8s01 ~]# ls
anaconda-ks.cfg  harbor  harbor-offline-installer-v1.6.1.tgz  keepalived.conf  nginx.sh
[root@mcwk8s01 ~]# cd harbor/
[root@mcwk8s01 harbor]# ls
common  docker-compose.chartmuseum.yml  docker-compose.clair.yml  docker-compose.notary.yml  docker-compose.yml  ha  harbor.cfg  harbor.v1.6.1.tar.gz  install.sh  LICENSE  NOTICE  open_source_license  prepare
[root@mcwk8s01 harbor]# vim harbor.cfg 
[root@mcwk8s01 harbor]# egrep "10.0.0.31|Harbor12345" harbor.cfg 
hostname = 10.0.0.31
harbor_admin_password = Harbor12345
[root@mcwk8s01 harbor]# 

如果需要使用https那修改下配置:ui_url_protocol = http

它是使用docker compose來編排部署的。所以我們可以去去下載一個。安裝方式如下鏈接參考

docker之docker-compose

 因爲harbor自己要起nginx,會佔用80服務,我們主機1上有nginx。那麼我們換到主機5上面去把=吧

[root@mcwk8s01 harbor]# scp /usr/local/bin/docker-compose 10.0.0.35:/usr/local/bin/
root@10.0.0.35's password: 
docker-compose                                                                                                                                                                 100%   10MB  23.5MB/s   00:00    
[root@mcwk8s01 harbor]# ls
common  docker-compose.chartmuseum.yml  docker-compose.clair.yml  docker-compose.notary.yml  docker-compose.yml  ha  harbor.cfg  harbor.v1.6.1.tar.gz  install.sh  LICENSE  NOTICE  open_source_license  prepare
[root@mcwk8s01 harbor]# cd ..
[root@mcwk8s01 ~]# ls
anaconda-ks.cfg  harbor  harbor-offline-installer-v1.6.1.tgz  keepalived.conf  nginx.sh
[root@mcwk8s01 ~]# scp -rp harbor 10.0.0.35:/root/
root@10.0.0.35's password: 
nginx.https.conf                                                                                                                                                               100% 3045     3.7MB/s   00:00    
notary.server.conf 

./prepare

[root@mcwk8s05 harbor]# ls
common  docker-compose.chartmuseum.yml  docker-compose.clair.yml  docker-compose.notary.yml  docker-compose.yml  ha  harbor.cfg  harbor.v1.6.1.tar.gz  install.sh  LICENSE  NOTICE  open_source_license  prepare
[root@mcwk8s05 harbor]# ./prepare 
Generated and saved secret to file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
[root@mcwk8s05 harbor]#

./install.sh

[root@mcwk8s05 harbor]# ./install.sh 

[Step 0]: checking installation environment ...

Note: docker version: 20.10.21

Note: docker-compose version: 1.21.0

[Step 1]: loading Harbor images ...
ad50e89f4922: Loading layer [==================================================>]  133.4MB/133.4MB
8c9a00a7f290: Loading layer [==================================================>]  73.29MB/73.29MB
078e22641f73: Loading layer [==================================================>]  3.584kB/3.584kB
5494f0d704cb: Loading layer [==================================================>]  3.072kB/3.072kB
34c7e304d18b: Loading layer [==================================================>]  4.096kB/4.096kB
ae9209f78c11: Loading layer [==================================================>]  3.584kB/3.584kB
1498359f7391: Loading layer [==================================================>]  9.728kB/9.728kB
Loaded image: goharbor/harbor-log:v1.6.1
bb738fd5b202: Loading layer [==================================================>]  23.38MB/23.38MB
51f6c7e046ae: Loading layer [==================================================>]  21.15MB/21.15MB
67ff79ae8340: Loading layer [==================================================>]  21.15MB/21.15MB
Loaded image: goharbor/harbor-jobservice:v1.6.1
b5be864bae6a: Loading layer [==================================================>]  83.89MB/83.89MB
9fdbae37c606: Loading layer [==================================================>]  3.072kB/3.072kB
c24b06c70085: Loading layer [==================================================>]   59.9kB/59.9kB
946c040a69da: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.6.1
747ac74b0475: Loading layer [==================================================>]  5.128MB/5.128MB
Loaded image: goharbor/nginx-photon:v1.6.1
3d4aae33f4f1: Loading layer [==================================================>]    683MB/683MB
3cb271cda7e0: Loading layer [==================================================>]   7.68kB/7.68kB
7ae402931bdb: Loading layer [==================================================>]  197.6kB/197.6kB
Loaded image: goharbor/harbor-migrator:v1.6.1
67747a74e108: Loading layer [==================================================>]  158.1MB/158.1MB
93f3d22257c7: Loading layer [==================================================>]  35.08MB/35.08MB
2eda636f347b: Loading layer [==================================================>]   2.56kB/2.56kB
7a3b4ef015e8: Loading layer [==================================================>]  35.08MB/35.08MB
Loaded image: goharbor/chartmuseum-photon:v0.7.1-v1.6.1
038c23438769: Loading layer [==================================================>]  23.38MB/23.38MB
a6a0201bf457: Loading layer [==================================================>]  26.88MB/26.88MB
aa0986b7d608: Loading layer [==================================================>]  7.168kB/7.168kB
830a350d7059: Loading layer [==================================================>]  11.32MB/11.32MB
3100afecce3d: Loading layer [==================================================>]  26.87MB/26.87MB
Loaded image: goharbor/harbor-ui:v1.6.1
15134eb6d277: Loading layer [==================================================>]  95.85MB/95.85MB
02cff5f31ca4: Loading layer [==================================================>]  6.656kB/6.656kB
3e43f3cb1d4c: Loading layer [==================================================>]  2.048kB/2.048kB
4ab1b74a5650: Loading layer [==================================================>]   7.68kB/7.68kB
9c78faccbd48: Loading layer [==================================================>]   2.56kB/2.56kB
158d4a16071f: Loading layer [==================================================>]   2.56kB/2.56kB
6a2fbfb6100b: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-db:v1.6.1
b15fe66f326a: Loading layer [==================================================>]  23.38MB/23.38MB
336e69120569: Loading layer [==================================================>]  3.072kB/3.072kB
f308142e2037: Loading layer [==================================================>]  3.072kB/3.072kB
3119c7884a49: Loading layer [==================================================>]  2.048kB/2.048kB
fafa9955d095: Loading layer [==================================================>]   22.8MB/22.8MB
4c53b946082a: Loading layer [==================================================>]   22.8MB/22.8MB
Loaded image: goharbor/registry-photon:v2.6.2-v1.6.1
0fee5e457010: Loading layer [==================================================>]  23.38MB/23.38MB
6d1b402441fc: Loading layer [==================================================>]  12.16MB/12.16MB
765a288fcf5a: Loading layer [==================================================>]   17.3MB/17.3MB
da4578643aee: Loading layer [==================================================>]  11.26kB/11.26kB
f02d275fa76f: Loading layer [==================================================>]  3.072kB/3.072kB
4a3d1e973223: Loading layer [==================================================>]  29.46MB/29.46MB
Loaded image: goharbor/notary-server-photon:v0.5.1-v1.6.1
918b224a19fd: Loading layer [==================================================>]  10.95MB/10.95MB
ff41acdef199: Loading layer [==================================================>]   17.3MB/17.3MB
4389d5e9282a: Loading layer [==================================================>]  11.26kB/11.26kB
8a0e0bb6ed63: Loading layer [==================================================>]  3.072kB/3.072kB
d437ffa494e0: Loading layer [==================================================>]  28.24MB/28.24MB
Loaded image: goharbor/notary-signer-photon:v0.5.1-v1.6.1
1c86e9f19207: Loading layer [==================================================>]  158.1MB/158.1MB
3b4698fe61a0: Loading layer [==================================================>]  10.93MB/10.93MB
8dbd6d55a6cd: Loading layer [==================================================>]  2.048kB/2.048kB
5cb748f1dcf1: Loading layer [==================================================>]  48.13kB/48.13kB
f86a42ee549b: Loading layer [==================================================>]  10.98MB/10.98MB
Loaded image: goharbor/clair-photon:v2.0.6-v1.6.1
18abf81cd9fd: Loading layer [==================================================>]  23.38MB/23.38MB
66a3e670c5b5: Loading layer [==================================================>]  15.58MB/15.58MB
9cdd51a1e20c: Loading layer [==================================================>]  15.36kB/15.36kB
9aedba3496f1: Loading layer [==================================================>]  15.58MB/15.58MB
Loaded image: goharbor/harbor-adminserver:v1.6.1


[Step 2]: preparing environment ...
Clearing the configuration file: ./common/config/adminserver/env
Clearing the configuration file: ./common/config/ui/env
Clearing the configuration file: ./common/config/ui/app.conf
Clearing the configuration file: ./common/config/ui/private_key.pem
Clearing the configuration file: ./common/config/db/env
Clearing the configuration file: ./common/config/jobservice/env
Clearing the configuration file: ./common/config/jobservice/config.yml
Clearing the configuration file: ./common/config/registry/config.yml
Clearing the configuration file: ./common/config/registry/root.crt
Clearing the configuration file: ./common/config/registryctl/env
Clearing the configuration file: ./common/config/registryctl/config.yml
Clearing the configuration file: ./common/config/nginx/nginx.conf
Clearing the configuration file: ./common/config/log/logrotate.conf
loaded secret from file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/ui/env
Generated configuration file: ./common/config/registry/config.yml
Generated configuration file: ./common/config/db/env
Generated configuration file: ./common/config/jobservice/env
Generated configuration file: ./common/config/jobservice/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/ui/app.conf
Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.


[Step 3]: checking existing instance of Harbor ...


[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis              ... done
Creating registry           ... done
Creating harbor-adminserver ... done
Creating harbor-db          ... done
Creating harbor-ui          ... done
Creating nginx              ... done
Creating harbor-jobservice  ... done

✔ ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://10.0.0.31. 
For more details, please visit https://github.com/goharbor/harbor .

[root@mcwk8s05 harbor]# 

查看導入的鏡像

[root@mcwk8s05 harbor]# 
[root@mcwk8s05 harbor]# docker images
REPOSITORY                                                        TAG             IMAGE ID       CREATED       SIZE
busybox                                                           latest          bc01a3326866   11 days ago   1.24MB
nginx                                                             latest          76c69feac34e   12 days ago   142MB
nginx                                                             1.14            295c7be07902   3 years ago   109MB
nginx                                                             1.14.2          295c7be07902   3 years ago   109MB
goharbor/chartmuseum-photon                                       v0.7.1-v1.6.1   f0a2dbee1ff1   4 years ago   350MB
goharbor/harbor-migrator                                          v1.6.1          60e8be845b35   4 years ago   798MB
goharbor/redis-photon                                             v1.6.1          6a67380bb061   4 years ago   210MB
goharbor/clair-photon                                             v2.0.6-v1.6.1   c4fcdbae7df2   4 years ago   302MB
goharbor/notary-server-photon                                     v0.5.1-v1.6.1   f1afd44d9f9b   4 years ago   209MB
goharbor/notary-signer-photon                                     v0.5.1-v1.6.1   83aa51867207   4 years ago   207MB
goharbor/registry-photon                                          v2.6.2-v1.6.1   f4cb5e83f0a4   4 years ago   196MB
goharbor/nginx-photon                                             v1.6.1          9ca888fe33b2   4 years ago   132MB
goharbor/harbor-log                                               v1.6.1          9b1ea3f29465   4 years ago   198MB
goharbor/harbor-jobservice                                        v1.6.1          9ca6fd371ca6   4 years ago   192MB
goharbor/harbor-ui                                                v1.6.1          305ee5b8952c   4 years ago   215MB
goharbor/harbor-adminserver                                       v1.6.1          a3e95f74984e   4 years ago   181MB
goharbor/harbor-db                                                v1.6.1          3bea3bff0190   4 years ago   219MB
siriuszg/kubernetes-dashboard-amd64                               v1.8.3          784cf2722f44   4 years ago   102MB
registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64   3.0             99e59f495ffa   6 years ago   747kB
[root@mcwk8s05 harbor]# 

運行服務和查看狀態:

docker-compose up -d   #應該是需要在服務的目錄下進行,好像是會讀取docker-compose.yml文件去部署

docker-compose ps

[root@mcwk8s05 harbor]# ls
common  docker-compose.chartmuseum.yml  docker-compose.clair.yml  docker-compose.notary.yml  docker-compose.yml  ha  harbor.cfg  harbor.v1.6.1.tar.gz  install.sh  LICENSE  NOTICE  open_source_license  prepare
[root@mcwk8s05 harbor]# docker-compose up -d
harbor-log is up-to-date
redis is up-to-date
registry is up-to-date
harbor-db is up-to-date
harbor-adminserver is up-to-date
harbor-ui is up-to-date
harbor-jobservice is up-to-date
nginx is up-to-date
[root@mcwk8s05 harbor]# 
[root@mcwk8s05 harbor]# 
[root@mcwk8s05 harbor]# docker-compose ps
       Name                     Command                  State                                                            Ports                                                      
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver   /harbor/start.sh                 Up (healthy)                                                                                                                   
harbor-db            /entrypoint.sh postgres          Up (healthy)   5432/tcp                                                                                                        
harbor-jobservice    /harbor/start.sh                 Up                                                                                                                             
harbor-log           /bin/sh -c /usr/local/bin/ ...   Up (healthy)   127.0.0.1:1514->10514/tcp                                                                                       
harbor-ui            /harbor/start.sh                 Up (healthy)                                                                                                                   
nginx                nginx -g daemon off;             Up (healthy)   0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:4443->4443/tcp,:::4443->4443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp
redis                docker-entrypoint.sh redis ...   Up             6379/tcp                                                                                                        
registry             /entrypoint.sh /etc/regist ...   Up (healthy)   5000/tcp                                                                                                        
[root@mcwk8s05 harbor]# 

訪問地址:http://10.0.0.35/

如下,進入了登錄頁面了

 

 默認用戶  admin   

默認用戶密碼 Harbor12345

登錄之後默認有個倉庫,是個公共的倉庫,我們可以往裏面上傳鏡像。我們主要用的項目和用戶。

harbor的基本使用

 harbor頁面的基本使用

 創建用戶

ASdf556433377*&&

 

 

 爲項目添加成員(管理員)

 

 

 推送鏡像的參考命令

這個配置的地址有問題,我們之前在31上配置的。傳到35上了,但是沒有修改配置,配置那麼多。我們重新部署一下吧

 停止服務

[root@mcwk8s05 harbor]# docker-compose stop
Stopping harbor-jobservice  ... done
Stopping nginx              ... done
Stopping harbor-ui          ... done
Stopping harbor-adminserver ... done
Stopping harbor-db          ... done
Stopping registry           ... done
Stopping redis              ... done
Stopping harbor-log         ... done
[root@mcwk8s05 harbor]# 

重新部署之後就對了。我是將harbor目錄刪除了,重新上傳的,但是剛剛創建的成員machangwei還在的,看來數據庫或者是存儲的數據是在別處,沒有受到影響嗎。

 

 推送鏡像到harbor

推送總結

1、配置http鏡像倉庫可信任
# vi /etc/docker/daemon.json
{"insecure-registries":["reg.ctnrs.com"]}
# systemctl restart docker
2、打標籤
# docker tag centos:6 reg.ctnrs.com/library/centos:6
3、上傳
# docker push reg.ctnrs.com/library/centos:6
4、下載
# docker pull reg.ctnrs.com/library/centos:6

推送案例

如推薦的推送案例,我們需要打上標籤,標籤地址是我們的項目訪問地址,然後push這個有倉庫地址標籤的鏡像

 打個標籤

[root@mcwk8s05 harbor]# docker images tomcat
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
tomcat       latest    3500a757f51d   3 days ago   473MB
[root@mcwk8s05 harbor]# docker tag tomcat 10.0.0.35/library/tomcat:v1
[root@mcwk8s05 harbor]# docker images tomcat
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
tomcat       latest    3500a757f51d   3 days ago   473MB
[root@mcwk8s05 harbor]# docker images 10.0.0.35/library/tomcat:v1
REPOSITORY                 TAG       IMAGE ID       CREATED      SIZE
10.0.0.35/library/tomcat   v1        3500a757f51d   3 days ago   473MB
[root@mcwk8s05 harbor]# 

我們推送鏡像需要登錄倉庫。docker默認是以https方式訪問鏡像倉庫的。我們這裏倉庫是使用的http的,那麼需要在docker配置文件里加上可信任

# vi /etc/docker/daemon.json
{"insecure-registries":["reg.ctnrs.com"]}
需要重啓服務
[root@mcwk8s05 harbor]# ip a|grep 10.0.0.35
    inet 10.0.0.35/24 brd 10.0.0.255 scope global eth0
[root@mcwk8s05 harbor]# cat /etc/docker/daemon.json 
{"registry-mirrors":["https://reg-mirror.qiniu.com/","https://docker.mirrors.ustc.edu.cn/","https://hub-mirror.c.163.com/"],
"insecure-registries":["10.0.0.35"]
}
[root@mcwk8s05 harbor]# systemctl restart docker
[root@mcwk8s05 harbor]# docker-compose ps
       Name                     Command                       State                                                                Ports                                                      
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver   /harbor/start.sh                 Exit 137                                                                                                                                
harbor-db            /entrypoint.sh postgres          Up (healthy)            5432/tcp                                                                                                        
harbor-jobservice    /harbor/start.sh                 Up                                                                                                                                      
harbor-log           /bin/sh -c /usr/local/bin/ ...   Up (healthy)            127.0.0.1:1514->10514/tcp                                                                                       
harbor-ui            /harbor/start.sh                 Up (health: starting)                                                                                                                   
nginx                nginx -g daemon off;             Up (health: starting)   0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:4443->4443/tcp,:::4443->4443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp
redis                docker-entrypoint.sh redis ...   Exit 128                                                                                                                                
registry             /entrypoint.sh /etc/regist ...   Up (healthy)            5000/tcp                                                                                                        
[root@mcwk8s05 harbor]# docker-compose up -d
harbor-log is up-to-date
Starting redis ... 
Starting harbor-adminserver ... 
Starting redis              ... done
Starting harbor-adminserver ... done
harbor-ui is up-to-date
nginx is up-to-date
harbor-jobservice is up-to-date
[root@mcwk8s05 harbor]# 
[root@mcwk8s05 harbor]# docker-compose ps
       Name                     Command                       State                                                                Ports                                                      
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver   /harbor/start.sh                 Up (health: starting)                                                                                                                   
harbor-db            /entrypoint.sh postgres          Up (healthy)            5432/tcp                                                                                                        
harbor-jobservice    /harbor/start.sh                 Up                                                                                                                                      
harbor-log           /bin/sh -c /usr/local/bin/ ...   Up (healthy)            127.0.0.1:1514->10514/tcp                                                                                       
harbor-ui            /harbor/start.sh                 Up (health: starting)                                                                                                                   
nginx                nginx -g daemon off;             Up (health: starting)   0.0.0.0:443->443/tcp,:::443->443/tcp, 0.0.0.0:4443->4443/tcp,:::4443->4443/tcp, 0.0.0.0:80->80/tcp,:::80->80/tcp
redis                docker-entrypoint.sh redis ...   Up                      6379/tcp                                                                                                        
registry             /entrypoint.sh /etc/regist ...   Up (healthy)            5000/tcp                                                                                                        
[root@mcwk8s05 harbor]# 

登錄倉庫並i推送鏡像到倉庫

[root@mcwk8s05 harbor]# docker login 10.0.0.35
Username: machangwei
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@mcwk8s05 harbor]# docker push 10.0.0.35/library/tomcat:v1
The push refers to repository [10.0.0.35/library/tomcat]
dac98e58cc38: Pushed 
052fe235dec6: Pushed 
8129280902f4: Pushed 
9e5fabf427d2: Pushed 
6657f9faac5f: Pushed 
3a87162a073c: Pushed 
f4a670ac65b6: Pushed 
v1: digest: sha256:8aaa923ea3dbd010cf77faf9e9ad0624fe19fcb5a3dae4cb34c235a3150c00cc size: 1788
[root@mcwk8s05 harbor]# 

查看harbor倉庫上,已經有了剛剛上傳的鏡像

 點擊進入,看到推送的信息

 我們再把nginx推送上去,把tomcat再推送第二個版本上去。需要注意的是,我們推送前一定要打上我們自己倉庫的地址的鏡像標籤,推送這個有標籤的鏡像,別直接推送未打標籤的,省的推送到別人的倉庫了。

[root@mcwk8s05 harbor]# docker images nginx:1.14
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        1.14      295c7be07902   3 years ago   109MB
[root@mcwk8s05 harbor]# docker images 10.0.0.35/library/tomcat:v1
REPOSITORY                 TAG       IMAGE ID       CREATED      SIZE
10.0.0.35/library/tomcat   v1        3500a757f51d   3 days ago   473MB
[root@mcwk8s05 harbor]# docker tag 10.0.0.35/library/tomcat:v1   10.0.0.35/library/tomcat:v2
[root@mcwk8s05 harbor]# docker images 10.0.0.35/library/tomcat:v2
REPOSITORY                 TAG       IMAGE ID       CREATED      SIZE
10.0.0.35/library/tomcat   v2        3500a757f51d   3 days ago   473MB
[root@mcwk8s05 harbor]# 
[root@mcwk8s05 harbor]# docker push nginx:1.14
The push refers to repository [docker.io/library/nginx]
82ae01d5004e: Layer already exists 
b8f18c3b860b: Preparing 
5dacd731af1b: Preparing 
^C
[root@mcwk8s05 harbor]# docker tag nginx:1.14  10.0.0.35/library/nginx:1.14
[root@mcwk8s05 harbor]# docker images 10.0.0.35/library/nginx:1.14
REPOSITORY                TAG       IMAGE ID       CREATED       SIZE
10.0.0.35/library/nginx   1.14      295c7be07902   3 years ago   109MB
[root@mcwk8s05 harbor]# 
[root@mcwk8s05 harbor]# docker push 10.0.0.35/library/nginx
Using default tag: latest
The push refers to repository [10.0.0.35/library/nginx]
tag does not exist: 10.0.0.35/library/nginx:latest
[root@mcwk8s05 harbor]# docker push 10.0.0.35/library/nginx:1.14
The push refers to repository [10.0.0.35/library/nginx]
82ae01d5004e: Pushed 
b8f18c3b860b: Pushed 
5dacd731af1b: Pushed 
1.14: digest: sha256:706446e9c6667c0880d5da3f39c09a6c7d2114f5a5d6b74a2fafd24ae30d2078 size: 948
[root@mcwk8s05 harbor]# docker push 10.0.0.35/library/tomcat:v2
The push refers to repository [10.0.0.35/library/tomcat]
dac98e58cc38: Layer already exists 
052fe235dec6: Layer already exists 
8129280902f4: Layer already exists 
9e5fabf427d2: Layer already exists 
6657f9faac5f: Layer already exists 
3a87162a073c: Layer already exists 
f4a670ac65b6: Layer already exists 
v2: digest: sha256:8aaa923ea3dbd010cf77faf9e9ad0624fe19fcb5a3dae4cb34c235a3150c00cc size: 1788
[root@mcwk8s05 harbor]# 

我們再看下,這個倉庫中的tomcat有兩個版本了

 

 倉庫中有兩個鏡像

 我們想要下載指定鏡像指定版本的話可以在這裏看下載地址,複製命令

 

 比如上面我們複製的是    docker pull 10.0.0.35/library/tomcat:v1

我們在另一臺主機,主機6上下載一下。我們下載的主機,由於harbor是http方式的,我們也需要添加配置,讓harbor主機是受信任的

[root@mcwk8s06 ~]# docker pull 10.0.0.35/library/tomcat:v1
Error response from daemon: Get "https://10.0.0.35/v2/": dial tcp 10.0.0.35:443: connect: connection refused
[root@mcwk8s06 ~]# vim /etc/docker/daemon.json 
[root@mcwk8s06 ~]# cat /etc/docker/daemon.json
{"registry-mirrors":["https://reg-mirror.qiniu.com/","https://docker.mirrors.ustc.edu.cn/","https://hub-mirror.c.163.com/"],
"insecure-registries":["10.0.0.35"]
}
[root@mcwk8s06 ~]# systemctl restart docker
[root@mcwk8s06 ~]# 
[root@mcwk8s06 ~]# docker pull 10.0.0.35/library/tomcat:v1
v1: Pulling from library/tomcat
e96e057aae67: Pull complete 
014fa72e018d: Pull complete 
3c9b94dcf278: Pull complete 
4624f8447672: Pull complete 
fbaf4e13e099: Pull complete 
fe482f3df622: Pull complete 
9c389ce12d0e: Pull complete 
Digest: sha256:8aaa923ea3dbd010cf77faf9e9ad0624fe19fcb5a3dae4cb34c235a3150c00cc
Status: Downloaded newer image for 10.0.0.35/library/tomcat:v1
10.0.0.35/library/tomcat:v1
[root@mcwk8s06 ~]# docker images 10.0.0.35/library/tomcat:v1
REPOSITORY                 TAG       IMAGE ID       CREATED      SIZE
10.0.0.35/library/tomcat   v1        3500a757f51d   3 days ago   473MB
[root@mcwk8s06 ~]# 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章