Docker登录Harbor私有仓库

说明

在安装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文件。


image.png | center | 651x186

  • 编辑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项)
//根据提示分别输入用户名和密码
评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值