如果想在容器宿主机的终端界面应用命令操作 harbor 库里的容器,须要先登录,否则无奈对容器做 pull 或者 push 等操作。登录的用户名和明码就是 harbor.yml 中定义的用来从 harbor UI 登录的用户名和明码,默认是 admin 和 Harbor12345 。

当然在登录之前,还要先做一步操作就是在配置文件 daemon.json(该文件默认不存在)中增加公有仓库 harbor 的地址 http://192.168.100.151:80 ,否则无奈登陆:

vim /etc/docker/daemon.json

配置如下,曾经装置的 harbor 默认应用 80 端口,在配置文件中必须把这个默认的端口 80 也写上,不能省略(晚期 Docker 版本是能够护疏忽这个 80 端口不写的):

{"registry-mirrors":["https://tdimi5ql.mirror.aliyuncs.com"],"insecure-registries":["http://192.168.100.151:80"]}

重启 docker 服务让仓库地址的配置失效:

systemctl restart docker.service

留神:
重启 docker 服务会导致容器全副进行运行。组成 harbor 服务的容器群要从新拉起。

登录 harbor 应用命令:

docker login [IP]:[PORT]
[root@k8s-master /data]# docker login 192.168.100.151:80Username: adminPassword: WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded

或者应用命令(不举荐此种在终端中应用显性明码的形式):

docker login [IP]:[PORT] -u [USERNAME] -p [PASSWORD]
[root@k8s-master /data]# docker login 192.168.100.151:80 -u admin -p Harbor12345WARNING! Using --password via the CLI is insecure. Use --password-stdin.WARNING! Your password will be stored unencrypted in /root/.docker/config.json.Configure a credential helper to remove this warning. Seehttps://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded

留神告警提醒!在生产环境中应防止在终端中输出显性明码。出于平安思考,首次登录 harbor UI 后应该立刻批改 admin 的明码!