centos7 harbor安装

Harbor 是 Vmwar 公司开源的 企业级的 Docker Registry 管理项目,它主要 提供 Dcoker Registry 管理UI,可基于角色访问控制, AD/LDAP 集成,日志审核等功能,完全的支持中文。Harbor 的所有组件都在 Dcoker 中部署,所以 Harbor 可使用 Docker Compose 快速部署。
 
1.下载harbor
这里采用离线安装 下载 harbor-offline-installer-v1.1.2.tgz 放入linux的/home/tools/目录
原地址下载超级慢,这里友情提供网盘 https://share.weiyun.com/3cc103ec4969f0544f0684459d52562d
2.解压
cd /home/tools/
tar xvf harbor-offline-installer-v1.1.2.tgz
3.修改配置 配置 Harbor配置参数被放在文件 harbor.cfg 中
cd ./harbor
vim ./harbor.cfg
  参考以下配置
#配置目标主机的主机名, 被用来访问Harbor ui 和镜像仓库的,可以配置为ip地址和全域名,比如 192.168.101.150 or docker-register.yourdomain.com. 不要使用 localhost or 127.0.0.1 为主机名
hostname = docker-register.yourdomain.com
#(http or https. 默认协议为 http) 该协议被用来访问 the UI and the token/notification 服务. 默认是 http. 想要设置https协议,请看链接 配置Harbor支持https协议.
ui_url_protocol = http
#(默认为 3) 设置在任务服务中最大的工作副本, 每一个image副本任务,会有一个worker从仓库中将所有的tag同步到远端。增大这个值回允许更多当前的副本任务,然而因为每个worker都会去消耗一定的网络/cpu/io等资源,必须根据系统的资源进行合理设置该值。
max_job_workers = 3 
#(on or off. 默认为on) 当设置为on的时候,会使用脚本去创建私钥和root证书去认证registry的token
customize_crt = on
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
secretkey_path = /data
admiral_url = NA
#配置Harbor来发送邮件,当然改配置并不是必须的 .注意:默认的ssl链接没有被启用,如果SMTP需要ssl支持,可以设置以下参数以支持
email_identity = 
email_server = smtp.163.com
email_server_port = 25
email_username = [email protected]
email_password = xxx
email_from = admin
email_ssl = false
#设置管理员内部密码,该密码紧紧在第一次启动Harbor的时候生效.在之后这个设置被忽略,管理员的密码将在UI中重新设置。 默认的用户名和密码如下: admin/Harbor12345 .
harbor_admin_password = admin-123
#被用来认证的方式,默认使用的是 db_auth,该认证会被肢解存储到数据库中。 如果需要设置LDAP方式认证需要使用ldap_auth.
auth_mode = db_auth
#mysql数据库root用户密码 db_auth模式.
db_password = root
#LDAP server LDAP认证方式 当 auth_mode 被设置为ldap_auth 的时候。
ldap_url = ldaps://ldap.mydomain.com
ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com
ldap_search_pwd = password
ldap_basedn = ou=people,dc=mydomain,dc=com
ldap_filter = (objectClass=person)
ldap_uid = uid 
ldap_scope = 3 
ldap_timeout = 5
#(on or off. Default is on) 启用和关闭用户注册功能.当被关闭,新用户职能通过admin用户去创建。 _注意: 当 auth_mode 被设置为 ldap_auth, self-registration 会被一直关闭,该参数也会被忽略
self_registration = off
#token过期时间,默认30分钟
token_expiration = 30
#项目创建权限 everyone:所有人,adminonly:管理员
project_creation_restriction = everyone
#(on or off. 默认 on) 该参数决定了当harbor盒远端的registry实例交互的时候是否使用SSL/TLS .设置为off 的时候,一般远端的registry会采用自签名或者未受信任的证书。
verify_remote_cert = on
 
4.执行安装
sudo ./install.sh
 
报异常缺少docker-compose
✖ Need to install docker-compose(1.7.1+) by yourself first and run this script again.

harbor docker-compose.yml  参考 http://wu1g119.iteye.com/blog/2388261

再次执行
sudo ./install.sh
 
 
5.安装完成
docker ps
 
可以看到
证明harbor启动成功
 6.web登录
输入 http://192.168.101.150/ 且设置账号密码
 
7.maven中使用仓库
1.)首先在harbor中新建项目hsd,且添加所属人员
========maven插件配置======================
2.)settings.xml 添加仓库密码
<servers>
     <!--docker私服-->
     <server>
        <id>docker-hub</id>
        <username>harbor项目人员的账号</username>
        <password>harbor项目人员的密码</password>
        <configuration>
          <email>harbor项目人员的邮箱地址</email>
        </configuration>
      </server>
</servers>
 
3.)
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>1.0.0</version>
    <configuration>
        <serverId>docker-hub</serverId>
        <registryUrl>http://192.168.101.150</registryUrl>
        <dockerHost>http://192.168.101.150:2375</dockerHost>
        <exposes>80</exposes>
        <pushImage>true</pushImage>
        <imageName>192.168.101.150/hsd/${project.artifactId}:${project.version}</imageName>
        <imageTags>
            <imageTag>1.0</imageTag>
        </imageTags>
        <dockerDirectory>src/main/docker</dockerDirectory>
        <skipDockerBuild>false</skipDockerBuild>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/Dockerfile</include>
                </includes>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.jar</include>
            </resource>
        </resources>
    </configuration>
</plugin>
 
发布
mvn clean install
启动
docker -H 192.168.101.150:2375 run -p 6060:6060 hsd/hsd-account-server:1.0
 
参考资料

猜你喜欢

转载自wu1g119.iteye.com/blog/2388255