一、Harbor介紹
????Docker容器應(yīng)用的開(kāi)發(fā)和運(yùn)行離不開(kāi)可靠的鏡像管理,雖然Docker官方也提供了公共的鏡像倉(cāng)庫(kù),但是從安全和效率等方面考慮,部署私有環(huán)境內(nèi)的Registry也是非常必要的。Harbor是由VMware公司開(kāi)源的企業(yè)級(jí)的Docker Registry管理項(xiàng)目,它包括權(quán)限管理(RBAC)、LDAP、日志審核、管理界面、自我注冊(cè)、鏡像復(fù)制和中文支持等功能
二、環(huán)境準(zhǔn)備 (1臺(tái)centos7的虛擬機(jī))
????????Harbor的所有服務(wù)組件都是在Docker中部署的,所以官方安裝使用Docker-compose快速部署,所以需要安裝Docker、Docker-compose。由于Harbor是基于Docker Registry V2版本,所以就要求Docker-ce版本不小于17.06.0,Docker-compose版本大于等于1.6.0
????????1、安裝docker-ce 及基礎(chǔ)環(huán)境
1:yum install -y yum-utils device-mapper-persistent-data lvm2
2:yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
3: yum list docker-ce.x86_64 --showduplicates |sort -r
4: yum install docker-ce-17.09.1.ce -y
? ? ? ?
????????2、安裝docker-compose????????
1、curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
或者
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.3.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
2、 chmod +x /usr/local/bin/docker-compose
3、 docker-compose --version
4、 docker-compose up
????????? ? ? ??? ? ? ? ? ? ??
三、安裝harbor (下載較慢)
? ? ? ? 1、下載harbor離線安裝包
1、wget https://github.com/goharbor/harbor/releases/download/v2.4.2/harbor-offline-installer-v2.4.2.tgz
2、tar -zxvf harbor-offline-installer-v2.4.2.tgz #解壓離線安裝包
? ? ? ? 2、配置harbor
1、cd harbor
2、cp harbor.yml.tmpl harbor.yml
3、vim harbor.yml
修改內(nèi)容:hostname = 10.130.77.28 #修改harbor的啟動(dòng)ip為你虛擬機(jī)的ip
harbor_admin_password = admin@123 #修改harbor的admin用戶的密碼
?????????3、啟動(dòng)harbor??
bash install.sh
?????????4、docker-compose ps 查看
?四、訪問(wèn)harbor(我這里是http://192.168.68.137/)? ?
1、新建個(gè)項(xiàng)目目錄
??2、命令行登陸harbor ( )
?注意:第一次登錄一般都會(huì)報(bào)錯(cuò)?
Error response from daemon: Get "https://192.168.68.137/v2/": dial tcp 10.130.77.48:443: connect: no route to host
[root@node-3 ~]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --insecure-registry 192.168.68.137
修改配置文件,ExecStart之后添加
重啟docker
systemctl daemon-reload
systemctl restart docker
?3、測(cè)試上傳鏡像到harbor
????????
root@host_137 ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
3f4ca61aafcd: Pull complete
50c68654b16f: Pull complete
3ed295c083ec: Pull complete
40b838968eea: Pull complete
88d3ab68332d: Pull complete
5f63362a3fa3: Pull complete
Digest: sha256:0047b729188a15da49380d9506d65959cce6d40291ccfb4e039f5dc7efd33286
Status: Downloaded newer image for nginx:latest
[root@host_137 ~]# docker docker tag nginx:latest 192.168.68.137/harbor/nginx:latest
docker: 'docker' is not a docker command.
See 'docker --help'
[root@host_137 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 1403e55ab369 5 days ago 142MB
goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
[root@host_137 ~]# docker tag nginx:latest 192.168.68.137/harbor/nginx:latest
[root@host_137 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.68.137/harbor/nginx latest 1403e55ab369 5 days ago 142MB
nginx latest 1403e55ab369 5 days ago 142MB
goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
[root@host_137 ~]# docker push 192.168.68.137/harbor/nginx
The push refers to a repository [192.168.68.137/harbor/nginx]
c72d75f45e5b: Layer already exists
9a0ef04f57f5: Layer already exists
d13aea24d2cb: Layer already exists
2b3eec357807: Layer already exists
2dadbc36c170: Layer already exists
8a70d251b653: Layer already exists
latest: digest: sha256:9a821cadb1b13cb782ec66445325045b2213459008a41c72d8d87cde94b33c8c size: 1570
[root@host_137 ~]#
查看鏡像倉(cāng)庫(kù)?
測(cè)試?yán)$R像 (先將本地的鏡像刪除)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-470853.html
[root@host_137 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 1403e55ab369 5 days ago 142MB
192.168.68.137/harbor/nginx latest 1403e55ab369 5 days ago 142MB
goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
[root@host_137 ~]# docker rmi 192.168.68.137/harbor/nginx
Untagged: 192.168.68.137/harbor/nginx:latest
Untagged: 192.168.68.137/harbor/nginx@sha256:9a821cadb1b13cb782ec66445325045b2213459008a41c72d8d87cde94b33c8c
[root@host_137 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 1403e55ab369 5 days ago 142MB
goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
[root@host_137 ~]# docker pull 192.168.68.137/harbor/nginx
Using default tag: latest
latest: Pulling from harbor/nginx
Digest: sha256:9a821cadb1b13cb782ec66445325045b2213459008a41c72d8d87cde94b33c8c
Status: Downloaded newer image for 192.168.68.137/harbor/nginx:latest
[root@host_137 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 1403e55ab369 5 days ago 142MB
192.168.68.137/harbor/nginx latest 1403e55ab369 5 days ago 142MB
goharbor/harbor-exporter v2.7.0 69796d5ea472 11 days ago 96.5MB
goharbor/chartmuseum-photon v2.7.0 3a1128c43ada 11 days ago 227MB
goharbor/redis-photon v2.7.0 cc91f43eb370 11 days ago 154MB
goharbor/trivy-adapter-photon v2.7.0 acf7683e6266 11 days ago 431MB
goharbor/notary-server-photon v2.7.0 cc32c079c5e8 11 days ago 113MB
goharbor/notary-signer-photon v2.7.0 1c7e9e9a0c92 11 days ago 110MB
goharbor/harbor-registryctl v2.7.0 6573a396157f 11 days ago 139MB
goharbor/registry-photon v2.7.0 4d015df21516 11 days ago 78.1MB
goharbor/nginx-photon v2.7.0 5f2878db2a82 11 days ago 154MB
goharbor/harbor-log v2.7.0 6b4a9a2855bb 11 days ago 161MB
goharbor/harbor-jobservice v2.7.0 cdde5030ac74 11 days ago 252MB
goharbor/harbor-core v2.7.0 f1aaf647100d 11 days ago 215MB
goharbor/harbor-portal v2.7.0 ea51148e87b6 11 days ago 162MB
goharbor/harbor-db v2.7.0 fff87d4d50e4 11 days ago 195MB
goharbor/prepare v2.7.0 f0f57240ce77 11 days ago 164MB
[root@host_137 ~]#
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-470853.html
到了這里,關(guān)于centos7搭建本地harbor倉(cāng)庫(kù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!