
























CentOS版本:7.4
Harbor版本:1.5.0
Docker版本:1.12.6
Docker Compose版本:1.21.2
[root@node3 ~]# yum search docker
[root@node3 ~]# yum install -y docker
[root@node3 ~]# systemctl start docker
[root@node3 ~]# systemctl status docker
[root@node3 ~]# docker version
[root@node3 ~]# docker info
[root@node3 ~]# systemctl enable docker
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.0.tgz
Harbor安装路径:/root/local/harbor
tar zxf harbor-offline-installer-v1.5.0.tgz -C /root/local
cd /root/local/harbor
vim harbor.cfg
修改hostname为本机IP地址
#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 = 10.72.77.176
./prepare
./install.sh
http://10.72.77.176
docker-compose down -v
官网配置说明:
https://github.com/vmware/harbor/blob/master/docs/configure_https.md
mkdir -p /data/cert && cd /data/cert
openssl genrsa -out ca.key 2048 #生成根证书私钥(无加密)
openssl req -x509 -new -nodes -key ca.key -days 10000 -out ca.crt -subj "/CN=Harbor-sz"
req 产生证书签发申请命令
-x509 签发X.509格式证书命令。X.509是最通用的一种签名证书格式。
-new 生成证书请求-key 指定私钥文件-nodes 表示私钥不加密
-out 输出-subj 指定用户信息 -days 有效期
openssl req -newkey rsa:4096 -nodes -sha256 -keyout server.key -out server.csr
echo subjectAltName = IP:10.72.77.176 > extfile.cnf
openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -extfile extfile.cnf -out server.crt
x509 签发X.509格式证书命令。
-req 表示证书输入请求。
-days 表示有效天数 -extensions 表示按OpenSSL配置文件v3_req项添加扩展。
-CA 表示CA证书,这里为ca.crt
-CAkey 表示CA证书密钥,这里为ca.key
-CAcreateserial表示创建CA证书序列号
-extfile 指定文件
vim harbor.cfg
#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 = 10.72.77.176
#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = https
#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key
# 如果如下目录不存在,请创建,如果有域名请按此格式依次创建
mkdir -p /etc/docker/certs.d/10.72.77.176
# 如果端口为443,则不需要指定。如果为自定义端口,请指定端口
# /etc/docker/certs.d/yourdomain.com:port
# 将ca根证书依次复制到上述创建的目录中
cp /data/cert/ca.crt /etc/docker/certs.d/10.72.77.176/
/install.sh
https://10.72.77.176
在公网上,一般情况下都不暴露默认端口,避免被攻击!
以下修改harbor的默认80端口为其他端口!
这里示例修改为7000端口!
注意:以下步骤都是在harbor安装目录下操作!!!
cd /root/local/harbor
vim docker-compose.yml
proxy:
image: vmware/nginx-photon:1.11.13
container_name: nginx
restart: always
volumes:
- ./common/config/nginx:/etc/nginx:z
networks:
- harbor
ports:
- 7000:80
- 443:443
- 4443:4443
./prepare
vim common/templates/registry/config.yml
auth:
token:
issuer: harbor-token-issuer
realm: $ui_url/service/token
rootcertbundle: /etc/registry/root.crt
service: harbor-registry
vim common/config/registry/config.yml
auth:
token:
issuer: harbor-token-issuer
realm: https://10.72.77.176/service/token
rootcertbundle: /etc/registry/root.crt
service: harbor-registry
注意:如果https端口使用的默认443的话,这里只要配置IP地址,不需要带端口号
vim /etc/docker/daemon.json
{
"insecure-registries": [
"10.72.77.176"
]
}
systemctl daemon-reload
systemctl restart docker.service
docker-compose stop
./install.sh
最后,测试验证:
# docker login 10.72.77.176:7000
Username: admin
Password:
Login Succeeded
ok,完成!
先进入harbor安装目录
cd /root/local/harbor
暂停harbor (docker容器stop,并不删除容器)
docker-compose stop
恢复harbor (恢复docker容器运行)
docker-compose start
停止harbor ( 停止并删除docker容器)
docker-compose down -v
启动harbor (启动所有docker容器)
docker-compose up -d
# 停止 harbor
docker-compose down -v
# 修改配置
vim harbor.cfg
# 执行./prepare已更新配置到docker-compose.yml文件
./prepare
# 启动 harbor
docker-compose up -d
日志目录 /var/log/harbor
数据目录 /data
其中最主要是 /data/database 和 /data/registry 目录,如果你要彻底重新安装harbor,删除这两个目录即可。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。