1、配置信息

主机

192.168.100.129 

2、安装前

docker已经安装

Docker-compose也需要安装,应为harbor会用到

安装教程https://www.cnblogs.com/zyb2016/p/13679797.html

安装Harbor

首先查看docker版本

我这里安装的是19.03.12,我安装对应的harbor1.8版本

https://github.com/goharbor/harbor/releases自行下载对应版本

3、安装harbor

解压到自己想解压的目录下

然后修改配置文件

vi /root/harbor/harbor.yml

说明如下

# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.100.129   #这里是本机地址,不要写127.0.0.1,

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 9999         #这是开放的端口,不写默认80 

# https related config   开发使用http,生成可以使用https并且配置certificate和private_key
 #https:          
#   # https port for harbor, default is 443
  # port: 443
#   # The path of cert and key files for nginx
   #certificate: /your/certificate/path
   #private_key: /your/private/key/path

# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433

# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: www6532695

# Harbor DB configuration
database:
  # The password for the root user of Harbor DB. Change this before any production use.
  password: root123

# The default data volume
data_volume: /usr/local/workspace/harbor/data

4、启动harbor

cd harbor目录,./install.sh直接安装

如果没有关闭防火墙自行开放端口https://www.cnblogs.com/zyb2016/p/12910483.html

5、harbor添加项目

 

 

 6、push镜像

命令如下

docker tag IMAGE(镜像ID) 192.168.100.129:9999/pda-service/pda-service
docker push 192.168.100.129:9999/pda-service/pda-service
 
这个报错是在本地上传私有镜像的时候遇到的报错:
Get https://192.168.100.129:9999/v2/: http: server gave HTTP response to HTT
原因是;harbor应该用http,但是docker使用了https
解决办法是:在docker server启动的时候,增加启动参数,默认使用HTTP访问:
 vim /usr/lib/systemd/system/docker.service
在ExecStart行后面增加  --insecure-registry  ip:9999 此处为haobor端口号(不会有人傻到这个ip都不知道替换吧)
 
修改完之后重启docker服务
systemctl daemon-reload 
systemctl restart docker
docker-compose up -d
此事应该还会报错:requested access to the resource is denied

解决办法使用docker login 192.168.100.129:9999登录下harbor就可以了,账号密码不用说了吧,肯定是harbor的账号密码

登录成功之后再次提交就ok了,成功如图