说明
在安装Harbor时,可以配置启用http或者https的访问方式。默认为http(非加密连接,数据传输不安全,使用相对简单);如果采用https的方式,使用TLS加密,数据传输更安全,但是需要配置证书,操作相对繁琐。
harbor.cfg文件:
#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 = http
#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
登录
无论采用http还是https的方式,在docker客户端远程登录Harbor都需要修改一些配置。
http
Docker如果需要从非SSL源管理镜像,也就是说如果Harbor采用http协议的方式安装,需要配置Docker配置文件的insecury-registry参数。
- 查找Docker的服务文件:登录到已经安装Docker的服务器,输入
systemctl status docker
查看Docker的service文件。

- 编辑docker.service文件:在ExecStart处添加 –insecure-registry 参数。
ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
--init-path=/usr/libexec/docker/docker-init-current \
--seccomp-profile=/etc/docker/seccomp.json \
--insecure-registry=192.168.26.252(Harbor地址) \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
- 重新加载service文件,重启docker服务。
systemctl daemon-reload
systemctl restart docker
登录测试:
docker login [ip地址或域名](Harbor地址,harbor.cfg文件中的hostname项)
//根据提示分别输入用户名和密码
https
Harbor采用https的方式交换数据,Docker客户端处需要配置签署 harbor 证书的 CA 证书。
- 在Docker客户端服务器上创建指定目录:/etc/docker/certs.d/[IP地址或域名](Harbor地址,harbor.cfg文件中的hostname项)
mkdir -p /etc/docker/certs.d/[IP地址或域名]
- 拷贝CA证书到上述目录中
登录测试:
docker login [IP地址或域名](Harbor地址,harbor.cfg文件中的hostname项)
//根据提示分别输入用户名和密码