2022-10-15 Docker Harbor安装

harbor

  1. github下载地址:自行选择版本进行下载 harbor-offline-installer-vx.x.x.tgz

前置需要docker、docker-compose这里不做介绍可看另一篇文章里有安装方法。

  1. 解压安装包
  2. 修改harbor安装的配置文件
# cp harbor.yml.tmpl  harbor.yml
# mkdir -p /opt/application/harbor     //用于存放harbor的持久化数据
harbor.yml配置文件主要修改参数如下:
hostname: 192.168.1.81          //设置访问地址,可以使用ip、域名,不可以设置为127.0.0.1或localhost。默认情况下,harbor使用的端口是80,若使用自定义的端口,除了要改docker-compose.yml文件中的配置外,这里的hostname也要加上自定义的端口,否则在docker login、push时会报错
#http配置
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 9999                      

#https配置(如不需要可不配置,注释掉)
# https related config
#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

#external_url: https://reg.mydomain.com:8433      //如果要启用外部代理,比如外层的NGINX、LB等,请取消注释external_url,当它启用时,hostname将不再使用。

harbor_admin_password: Harbor12345         //admin密码

 

#数据库配置
database:
# The password for the root user of Harbor DB. Change this before any production use.
password: root123
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: 50
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 100 for postgres.
max_open_conns: 100


#持久化数据目录

data_volume: /opt/docker/harbor/data

……
  1. 执行安装脚本
./install.sh

直接结束后即可通过 http://192.168.1.81:9999 admin Harbor12345访问

常见问题

上传下载镜像

  1. 先在配置/etc/docker/daemon.json中添加docker镜像仓库:

重启docker 服务

systemctl restart docker

  1. /etc/docker/daemon.json中添加:
{
	"insecure-registries":["192.168.1.81:9999"]
}
  1. 上传镜像时先登录
docker login 192.168.1.81:9999
Username: admin
Password: 
Error response from daemon: Get https://192.18.0.8:9999/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
  1. 推送镜像到仓库中
docker push 192.168.1.81:9999/image:tag

更新harbor配置

如果需要更改harbor的配置项,可按以下步骤进行修改更新

docker-compose down -v
vim /usr/local/harbor/harbor.yml
./prepare
docker-compose up -d

配置自启

vim /usr/lib/systemd/system/harbor.service

[Unit]
Description=harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
Documentation=http://github.com/vmware/harbor

[Service]
Type=simple
Restart=on-failure
RestartSec=5
# 注意路径需要根据自己存储位置修改
ExecStart=/usr/local/bin/docker-compose -f  /opt/docker/harbor/harbor/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f  /opt/docker/harbor/harbor/docker-compose.yml down

[Install]
WantedBy=multi-user.target

设置自启:

systemctl daemon-reload && systemctl enable harbor && systemctl restart harbor && systemctl status harbor

参考文章

harbor搭建及使用

Harbor 部署安装

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值