Linux安裝部署docker habor私服

1、安裝部署docker服務

2、安裝部署docker-compose

下載docker-compose文件 https://github.com/docker/compose/releases/tag/1.26.0-rc4

 

下載賦予權限,查看docker-compose版本 

[root@manage-host root]# wget https://github.com/docker/compose/releases/download/1.26.0-rc4/docker-compose-Linux-x86_64
[root@manage-host root]# cd /usr/local/bin/
[root@manage-host bin]# mv /root/docker-compose-Linux-x86_64 docker-compose
[root@manage-host bin]# chmod +x docker-compose
[root@manage-host bin]# docker-compose -version
docker-compose version 1.26.0-rc4, build d279b7a8

 3、下載harbor-offline-installer-v1.10.3-rc1.tgz

下載url:https://github.com/goharbor/harbor/releases/tag/v1.10.3-rc1

[root@manage-host root]# tar -xf harbor-offline-installer-v1.10.3-rc1.tgz

4、修改配置文件

5、手動生成我們的ssl證書

[root@manage-host ~]# openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /usr/local/harbor/ssl/yunson.key -out /usr/local/harbor/ssl/yunson.crt
Generating a 2048 bit RSA private key
............................+++
.......................................+++
writing new private key to '/usr/local/ssl/yunson.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:guangdong
Locality Name (eg, city) [Default City]:shenzhen
Organization Name (eg, company) [Default Company Ltd]:yiyuexin
Organizational Unit Name (eg, section) []:yunwei
Common Name (eg, your name or your server's hostname) []:yunson
Email Address []:[email protected]

6、開始安裝

[root@manage-host harbor]# ./install.sh 

[Step 0]: checking if docker is installed ...

Note: docker version: 19.03.9

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 1.26.0

[Step 2]: loading Harbor images ...
872a1466e826: Loading layer [==================================================>]   34.5MB/34.5MB
be67e6ec1f3f: Loading layer [==================================================>]  115.3MB/115.3MB
914f33566e33: Loading layer [==================================================>]  12.15MB/12.15MB
b686f12ae6b2: Loading layer [==================================================>]  3.072kB/3.072kB
c99f3ff6109e: Loading layer [==================================================>]  49.15kB/49.15kB
aeb081ad9f35: Loading layer [==================================================>]  3.584kB/3.584kB
0ec81192be0b: Loading layer [==================================================>]  13.03MB/13.03MB
Loaded image: goharbor/clair-photon:v1.10.3
d4cca6fd74a3: Loading layer [==================================================>]  332.6MB/332.6MB
356dc688ba77: Loading layer [==================================================>]  135.2kB/135.2kB
Loaded image: goharbor/harbor-migrator:v1.10.3
fd97d48c06ea: Loading layer [==================================================>]  81.45MB/81.45MB
d49da9a1a2f7: Loading layer [==================================================>]  48.48MB/48.48MB
6a9b1e8e74b5: Loading layer [==================================================>]   2.56kB/2.56kB
b6700e937fe0: Loading layer [==================================================>]  1.536kB/1.536kB
534a12ed8a4a: Loading layer [==================================================>]  157.2kB/157.2kB
b5dd6d5a1d9a: Loading layer [==================================================>]   2.93MB/2.93MB
Loaded image: goharbor/prepare:v1.10.3
ad577e8cf701: Loading layer [==================================================>]  10.28MB/10.28MB
66387ca02ee8: Loading layer [==================================================>]  7.697MB/7.697MB
00c21a3c3959: Loading layer [==================================================>]  223.2kB/223.2kB
0c05972d18e0: Loading layer [==================================================>]  195.1kB/195.1kB
c791dea236d1: Loading layer [==================================================>]  15.36kB/15.36kB
ea9a90e0e4a9: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-portal:v1.10.3
81515ba8952e: Loading layer [==================================================>]  12.21MB/12.21MB
b7d1a020301c: Loading layer [==================================================>]  42.51MB/42.51MB
394238cfc274: Loading layer [==================================================>]  5.632kB/5.632kB
b6845410390b: Loading layer [==================================================>]  40.45kB/40.45kB
3a835e6eea94: Loading layer [==================================================>]  42.51MB/42.51MB
41ad1f6ae8c6: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v1.10.3
0cad3c46a14c: Loading layer [==================================================>]  49.89MB/49.89MB
f577bda75d48: Loading layer [==================================================>]  3.584kB/3.584kB
802dbfc4dfc8: Loading layer [==================================================>]  3.072kB/3.072kB
5f1d6bc3a32b: Loading layer [==================================================>]   2.56kB/2.56kB
e1bed7b28702: Loading layer [==================================================>]  3.072kB/3.072kB
710ecdbe1051: Loading layer [==================================================>]  3.584kB/3.584kB
bd217b788544: Loading layer [==================================================>]  12.29kB/12.29kB
7bca055ec6b5: Loading layer [==================================================>]  5.632kB/5.632kB
Loaded image: goharbor/harbor-log:v1.10.3
0c5a551b5205: Loading layer [==================================================>]  8.441MB/8.441MB
8504717d8907: Loading layer [==================================================>]  3.584kB/3.584kB
84ec6055f288: Loading layer [==================================================>]  3.072kB/3.072kB
0a1bbb62cb99: Loading layer [==================================================>]  20.94MB/20.94MB
aae77d57f625: Loading layer [==================================================>]  21.76MB/21.76MB
Loaded image: goharbor/registry-photon:v1.10.3
a3dd38bf9f54: Loading layer [==================================================>]  8.435MB/8.435MB
39e61bef2942: Loading layer [==================================================>]  6.239MB/6.239MB
0fc0828baaca: Loading layer [==================================================>]  14.61MB/14.61MB
cfd5f381f9ff: Loading layer [==================================================>]  28.25MB/28.25MB
272062d630a8: Loading layer [==================================================>]  22.02kB/22.02kB
ad285ac50001: Loading layer [==================================================>]  49.09MB/49.09MB
Loaded image: goharbor/notary-signer-photon:v1.10.3
840eaa67357d: Loading layer [==================================================>]  85.82MB/85.82MB
6d49a6ead967: Loading layer [==================================================>]  3.072kB/3.072kB
f09c234868b4: Loading layer [==================================================>]   59.9kB/59.9kB
f9b0c18249b7: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.10.3
334cd059f255: Loading layer [==================================================>]  10.28MB/10.28MB
Loaded image: goharbor/nginx-photon:v1.10.3
81b7a18e70eb: Loading layer [==================================================>]  8.441MB/8.441MB
02ef091ac105: Loading layer [==================================================>]   9.71MB/9.71MB
1b5d16ea5b87: Loading layer [==================================================>]   9.71MB/9.71MB
Loaded image: goharbor/clair-adapter-photon:v1.10.3
574054caad35: Loading layer [==================================================>]  63.57MB/63.57MB
f4887b65ee9e: Loading layer [==================================================>]  62.92MB/62.92MB
4467d474558d: Loading layer [==================================================>]  5.632kB/5.632kB
87d80a0e6c3e: Loading layer [==================================================>]  2.048kB/2.048kB
8e28995b67fe: Loading layer [==================================================>]   2.56kB/2.56kB
c36d88bf2c7d: Loading layer [==================================================>]   2.56kB/2.56kB
d122b7830818: Loading layer [==================================================>]   2.56kB/2.56kB
dda55c308f32: Loading layer [==================================================>]  10.24kB/10.24kB
Loaded image: goharbor/harbor-db:v1.10.3
d696172c1900: Loading layer [==================================================>]  12.21MB/12.21MB
a5fd0a170b26: Loading layer [==================================================>]  49.37MB/49.37MB
Loaded image: goharbor/harbor-jobservice:v1.10.3
27120a5a4781: Loading layer [==================================================>]   8.44MB/8.44MB
19e3ec376f86: Loading layer [==================================================>]   67.5MB/67.5MB
809165a4c4d7: Loading layer [==================================================>]  3.072kB/3.072kB
50f9904a5147: Loading layer [==================================================>]  3.584kB/3.584kB
476615302c11: Loading layer [==================================================>]  68.33MB/68.33MB
Loaded image: goharbor/chartmuseum-photon:v1.10.3
17b695b39088: Loading layer [==================================================>]  8.441MB/8.441MB
c53135e53a1d: Loading layer [==================================================>]  3.584kB/3.584kB
33f4b1b7f236: Loading layer [==================================================>]  20.94MB/20.94MB
cbf9f2805bb4: Loading layer [==================================================>]  3.072kB/3.072kB
a0354f1ab3dd: Loading layer [==================================================>]  8.662MB/8.662MB
cec5fa1664ac: Loading layer [==================================================>]  30.42MB/30.42MB
Loaded image: goharbor/harbor-registryctl:v1.10.3
cb3c900edccf: Loading layer [==================================================>]  16.04MB/16.04MB
578c1c343a53: Loading layer [==================================================>]  28.25MB/28.25MB
a3d3128c7f26: Loading layer [==================================================>]  22.02kB/22.02kB
f9b3e3ba2b14: Loading layer [==================================================>]  50.52MB/50.52MB
Loaded image: goharbor/notary-server-photon:v1.10.3


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registry/root.crt
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir



[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating harbor-db     ... done
Creating registryctl   ... done
Creating redis         ... done
Creating harbor-portal ... done
Creating registry      ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----

note:harbor的一些操作命令

# 停止harbor
$ sudo docker-compose stop

# 啓動harbor
$ sudo docker-compose start

# 重新配置harbor
$ sudo docker-compose down -v
$ vim harbor.yml
$ sudo prepare
$ sudo docker-compose up -d

# 刪除Harbor的容器,同時將鏡像數據和Harbor的數據庫文件保留在文件系統中:
$ sudo docker-compose down -v

# 刪除Harbor的數據庫和鏡像數據以進行重新安裝:
$ rm -r /data/database
$ rm -r /data/registry

# 如果要一起安裝Notary,Clair和圖表存儲庫服務,則應在prepare命令中包括所有組件:
$ sudo docker-compose down -v
$ vim harbor.yml
$ sudo prepare --with-notary --with-clair --with-chartmuseum
$ sudo docker-compose up -d

7、在瀏覽器上輸入域名,我是內網自己配置的證書,登錄後如下

管理員用戶admin登錄,默認密碼:Harbor12345

創建一個用戶,後登錄,再得到如下,然後再創建一個項目(選擇公開)

8、客戶端上修改registry,如下

[root@master harbor]# cat /etc/docker/daemon.json 
{
	"insecure-registries": ["https://registry.yunson.com"]
}

重啓docker服務

[root@master harbor]# systemctl restart docker

將我們的鏡像文件做tag

[root@master harbor]# docker tag openapi:v1.1.0  registry.yunson.com/gridcloud/openapi:v1.1.0

[root@master harbor]# docker images
REPOSITORY                                                                     TAG                 IMAGE ID            CREATED             SIZE
openapi                                                                        v1.1.0              154221d0cfd7        2 weeks ago         787MB
registry.yunson.com/gridcloud/openapi                                          v1.1.0              154221d0cfd7        2 weeks ago         787MB

在客戶端上配置好hosts文件,再將我們tag好的鏡像push到我們的鏡像庫中

首先我們需要登錄到我們的docker鏡像倉庫

[root@master harbor]# docker login registry.yunson.com
Username: gridcloud
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

其次纔是我們將鏡像push

[root@master harbor]# docker push registry.yunson.com/gridcloud/openapi:v1.1.0 
The push refers to repository [registry.yunson.com/gridcloud/openapi]
a86197b4d74e: Pushed 
9de8d23664e8: Pushed 
4c0ddd873ea6: Pushed 
3d440c18b724: Pushed 
33bebfc29b11: Pushed 
35c20f26d188: Pushed 
c3fe59dd9556: Pushed 
6ed1a81ba5b6: Pushed 
a3483ce177ce: Pushed 
ce6c8756685b: Pushed 
30339f20ced0: Pushed 
0eb22bfb707d: Pushed 
a2ae92ffcd29: Pushed 
v1.1.0: digest: sha256:6a1f7a900c1a3096439db37063360a82b0377321c03ce3235e4297aa8c27088b size: 3046

9、最後我們在web界面上查看我們的鏡像

10、我們在另外一臺機器上測試結果如下

[root@node2 ~]# docker images
REPOSITORY                                                                     TAG                 IMAGE ID            CREATED             SIZE
openapi                                                                        v1.1.0              154221d0cfd7        2 weeks ago         787MB
[root@node2 ~]# docker pull registry.yunson.com/gridcloud/openapi:v1.1.0
v1.1.0: Pulling from gridcloud/openapi
Digest: sha256:6a1f7a900c1a3096439db37063360a82b0377321c03ce3235e4297aa8c27088b
Status: Downloaded newer image for registry.yunson.com/gridcloud/openapi:v1.1.0
registry.yunson.com/gridcloud/openapi:v1.1.0
[root@node2 ~]# docker images
REPOSITORY                                                                     TAG                 IMAGE ID            CREATED             SIZE
openapi                                                                        v1.1.0              154221d0cfd7        2 weeks ago         787MB
registry.yunson.com/gridcloud/openapi                                          v1.1.0              154221d0cfd7        2 weeks ago         787MB

 至此我們的docker harbor私服已經部署成功

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