查看 harbor 容器的状态,目前并不是全副失常运行(Up (healthy)),此时无法访问 harbor 仓库:
[root@k8s-master harbor]# docker-compose psName Command State Portsharbor-core /harbor/harbor_core Exit 2harbor-db /docker-entrypoint.sh Up (healthy) 5432/tcpharbor-jobservice /harbor/harbor_jobservice ... Up (unhealthy)harbor-log /bin/sh -c /usr/local/bin/ ... Up (healthy) 127.0.0.1:1514->10514/tcpharbor-portal nginx -g daemon off; Up (healthy) 8080/tcpnginx nginx -g daemon off; Exit 1redis redis-server /etc/redis.conf Up (healthy) 6379/tcpregistry /home/harbor/entrypoint.sh Up (healthy) 5000/tcpregistryctl /home/harbor/start.sh Up (healthy)
尝试重启 harbor 失败:
[root@k8s-master harbor]# docker-compose restartRestarting harbor-jobservice ... doneRestarting nginx ... doneRestarting harbor-core ... doneRestarting redis ... doneRestarting registry ... errorRestarting registryctl ... errorRestarting harbor-db ... errorRestarting harbor-portal ... doneRestarting harbor-log ... doneERROR: for registry Cannot restart container 5e34911c8b66152bdd7492f05dec74b11ffd314d5aaedac6e8e5104808f7a098: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refusedERROR: for harbor-db Cannot restart container 0d95056b01feb3bd66332a95170e95eec727e905ebc092b546704ed31e36117b: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refusedERROR: for registryctl Cannot restart container 9be00e977d4f149b55dee17ebac1a9340879c3f32888aeacf89008d1f5fcb346: failed to initialize logging driver: dial tcp 127.0.0.1:1514: connect: connection refused
解决办法:
先彻底敞开 harbor:[root@k8s-master harbor]# docker-compose stopStopping harbor-jobservice ... doneStopping nginx ... doneStopping harbor-core ... doneStopping redis ... doneStopping harbor-portal ... doneStopping harbor-log ... done
再启动 harbor 胜利:
[root@k8s-master harbor]# docker-compose startStarting log ... doneStarting registry ... doneStarting registryctl ... doneStarting postgresql ... doneStarting portal ... doneStarting redis ... doneStarting core ... doneStarting jobservice ... doneStarting proxy ... done
起因:
harbor 各个组件的启动程序具备肯定的依赖关系,而 docker-compose restart 默认不能读取这种依赖关系(很沙雕的设定)。所以通常重启 harbor 倡议先 stop 而后再 start 。