一:用途
Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器。
二:安装docker-ce
环境:阿里云轻量应用服务器CentOS 7.3
这里通过yum Docker源仓库安装:
①安装yum 管理依赖包
sudo yum install-y yum-utils device-mapper-persistent-data lvm2
②添加Docker 源仓库
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
③安装Docker CE
sudo yum install docker-ce docker-ce-cli containerd.io
三:安装docker-compose
参考这篇博客:https://www.cnblogs.com/wucaiyun1/p/11811112.html
四:安装harbor
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
①下载harbor
wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.6.1.tgz
或者到github releases下载
https://github.com/goharbor/harbor/releases
②配置安装(http方式)
[root@iZuf6hcb8yumasfp52oemxZ ailala]# tar -xf harbor-offline-installer-v1.6.1.tgz
[root@iZuf6hcb8yumasfp52oemxZ ailala]# cd harbor
[root@iZuf6hcb8yumasfp52oemxZ harbor]# vi harbor.yml
[root@iZuf6hcb8yumasfp52oemxZ harbor]# ./prepare
[root@iZuf6hcb8yumasfp52oemxZ harbor]# ./install
③登录
五:上传镜像到harbor仓库
在本机配置harbor仓库http可信
/etc/docker/daemon.json中添加“"insecure-registries":["reg.slito.com"]”,不然会报错,默认是走https的,重启docker;
登录harbor仓库
[root@iZuf6hcb8yumasfp52oemxZ harbor]# docker login fixedbug.work:88
Username: admin
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@iZuf6hcb8yumasfp52oemxZ harbor]# docker tag mysql:8 fixedbug.work:88/library/mysql:v1
[root@iZuf6hcb8yumasfp52oemxZ harbor]# docker push fixedbug.work:88/library/mysql:v1
The push refers to repository [fixedbug.work:88/library/mysql]
55f5c7d40658: Pushed
8d0c9963a6ad: Pushed
17b62e7a629c: Pushed
8eae701cdfcf: Pushing 31.11MB/341.1MB
d4078c1b9fdb: Pushed
8eae701cdfcf: Pushed
2a9aab74013a: Pushing 33.62MB/44.77MB
414373ffccb4: Pushed
2a9aab74013a: Pushed
51734435c93c: Pushed
5a8a245abd1c: Pushed
99b5261d397c: Pushing 23.78MB/55.34MB
99b5261d397c: Pushed
v1: digest: sha256:a65e1689b806ccb757887565a3c1d8e7467f14621012d472076cad4117eb06f3 size: 2828
[root@iZuf6hcb8yumasfp52oemxZ harbor]#
在harbor中查看
下载harbor中的镜像
[root@iZuf6hcb8yumasfp52oemxZ ~]# docker rmi fixedbug.work:88/library/mysql:v1
Untagged: fixedbug.work:88/library/mysql:v1
Untagged: fixedbug.work:88/library/mysql@sha256:a65e1689b806ccb757887565a3c1d8e7467f14621012d472076cad4117eb06f3
[root@iZuf6hcb8yumasfp52oemxZ ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 8 d435eee2caa5 12 days ago 456MB
goharbor/chartmuseum-photon v0.9.0-v1.9.3 c7ccd1b8e8df 2 weeks ago 131MB
goharbor/harbor-migrator v1.9.3 b0ff59a8111a 2 weeks ago 362MB
goharbor/redis-photon v1.9.3 33aaebc86b13 2 weeks ago 111MB
goharbor/clair-photon v2.1.0-v1.9.3 ccf50ab9d2c8 2 weeks ago 170MB
goharbor/notary-server-photon v0.6.1-v1.9.3 605e9ad80cf4 2 weeks ago 146MB
goharbor/notary-signer-photon v0.6.1-v1.9.3 4441a47e8f76 2 weeks ago 143MB
goharbor/harbor-registryctl v1.9.3 27af14c21462 2 weeks ago 103MB
goharbor/registry-photon v2.7.1-patch-2819-2553-v1.9.3 4c51bdb781e2 2 weeks ago 85.7MB
goharbor/nginx-photon v1.9.3 c6934119da35 2 weeks ago 44MB
goharbor/harbor-log v1.9.3 00a3acdb5d11 2 weeks ago 82.3MB
goharbor/harbor-jobservice v1.9.3 a3288107fff4 2 weeks ago 141MB
goharbor/harbor-core v1.9.3 9d394b9f6b49 2 weeks ago 155MB
goharbor/harbor-portal v1.9.3 6f5b0504c96b 2 weeks ago 51.4MB
goharbor/harbor-db v1.9.3 6004d1d5f272 2 weeks ago 148MB
goharbor/prepare v1.9.3 272365739d13 2 weeks ago 149MB
[root@iZuf6hcb8yumasfp52oemxZ ~]# docker pull fixedbug.work:88/library/mysql:v1
v1: Pulling from library/mysql
Digest: sha256:a65e1689b806ccb757887565a3c1d8e7467f14621012d472076cad4117eb06f3
Status: Downloaded newer image for fixedbug.work:88/library/mysql:v1
fixedbug.work:88/library/mysql:v1
[root@iZuf6hcb8yumasfp52oemxZ ~]# docker images | grep mysql
mysql 8 d435eee2caa5 12 days ago 456MB
fixedbug.work:88/library/mysql v1 d435eee2caa5 12 days ago 456MB