开始
网上找的步骤都有点问题,不能做到step by step成功,所以记录下我的步骤。
包准备
-
harbor包下载,我下的是离线版
https://github.com/goharbor/harbor/releases -
docker-compose 和 docker 自行安装
安装
tar zxvf harbor-offline-installer-v2.8.3.tgz -C /usr/local/
cd /usr/local/harbor/
cp harbor.yml.tmpl harbor.yml
vim harbor.yml
## 只用修改hostname和http端口,再把https的内容删除或者注释
hostname: 192.168.7.135
http:
port: 1180
保存,退出
./install.sh
- 打开浏览器输入
192.168.7.135:1180
,默认账户admin/Harbor12345
,可以在harbor.yml
中修改。
在项目里可以看到有library这个默认项目,这样就安装完毕了。
测试
先上传一个包,在本机上操作
[root@localhost harbor]# docker login -u admin -p Harbor12345 http://127.0.0.1:1180
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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@localhost harbor]# docker pull httpd
[root@localhost harbor]# docker tag httpd:latest 127.0.0.1:1180/library/httpd:v1
[root@localhost harbor]# docker push 127.0.0.1:1180/library/httpd:v1
The push refers to repository [127.0.0.1:1180/library/httpd]
deefaa620a71: Pushed
9cff3206f9a6: Pushed
15e4bf5d0804: Pushed
1da636a1aa95: Pushed
2edcec3590a4: Pushed
v1: digest: sha256:57c1e4ff150e2782a25c8cebb80b574f81f06b74944caf972f27e21b76074194 size: 1365
去页面上刷新一下,就可以看到上传的包了。
在其它机器上下载
另起一台机器192.168.7.136,先装上docker
[root@localhost harbor]# vim /etc/docker/daemon.json
{
"insecure-registries": ["192.168.7.135:1180"]
}
[root@localhost harbor]# systemctl daemon-reload && systemctl restart docker
[root@localhost system]# docker login -u admin -p Harbor12345 http://192.168.7.135:1180
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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@localhost system]# docker pull 192.168.7.135:1180/library/httpd:v1
v1: Pulling from library/httpd
a2abf6c4d29d: Pull complete
dcc4698797c8: Pull complete
41c22baa66ec: Pull complete
67283bbdd4a0: Pull complete
d982c879c57e: Pull complete
Digest: sha256:57c1e4ff150e2782a25c8cebb80b574f81f06b74944caf972f27e21b76074194
Status: Downloaded newer image for 192.168.7.135:1180/library/httpd:v1
192.168.7.135:1180/library/httpd:v1
[root@localhost system]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgis/postgis 15-3.3 a716de7a5abb 9 months ago 589MB
192.168.7.135:1180/library/httpd v1 dabbfbe0c57b 19 months ago 144MB
妥。