安装Harbor,首先要安装docker 和 docker-compose
$ yum install -y yum-utils device-mapper-persistent-data lvm2
$ yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
$ yum makecache fast
$ yum -y install docker-ce
$ systemctl start docker
$ curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ chmod +x /usr/local/bin/docker-compose
$ yum install bash-completion $ curl -L https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
$ docker-compose --version
$ wget -P /usr/local/src/ https://github.com/vmware/harbor/releases/download/v1.2.0/harbor-online-installer-v1.2.0.tgz
$ tar zxf harbor-online-installer-v1.2.0.tgz -C /usr/local/
$ cd /usr/local/harbor/ $ vim /usr/local/harbor/harbor.cfg
? Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.
Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.cfg bacause notary must run under https.
Please set --with-clair if needs enable Clair in Harbor
$ ./install.sh
查看Harbor # docker-compose ps 启动Harbor # docker-compose start 停止Harbor # docker-comose stop 重启Harbor # docker-compose restart
ERROR: for nginx UnixHTTPConnectionPool(host=‘localhost‘, port=None): Read timed out. (read timeout=60)
ERROR: for harbor-log UnixHTTPConnectionPool(host=‘localhost‘, port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
$ vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://njrds9qc.mirror.aliyuncs.com"],
"insecure-registries":["192.168.38.23"]
}
然后依次执行如下命令:
$ docker-compose stop $ systemctl daemon-reload $ systemctl restart docker $ docker-compose up -d
docker tag 83f3f8af3613 192.168.38.23/library/tomcat:7.0.69-jre7
$ docker login 192.168.38.23 Username: admin Password:
用户名密码:admin / Harbor12345
备注:如果登录时出现 Error response from daemon: Get http://192.168.38.23/v2/: Get http://harbor/service/token?account=admin&client_id=docker&offline_token=true&service=harbor-registry: dial tcp: lookup harbor on 192.168.38.2:53: no such host.
则需要执行第5步操作,配置TLS证书
(4)客户端push
push命令格式: docker push harbor/library/IMAGE[:TAG]
$ docker push 192.168.38.23/library/tomcat:7.0.69-jre7
hostname = 192.168.38.23
ui_url_protocol = https
ssl_cert = /etc/certs/ca.crt
ssl_cert_key = /etc/certs/ca.key
$ mkdir /etc/certs $ openssl genrsa -out /etc/certs/ca.key 2048 Generating RSA private key, 2048 bit long modulus ....+++ ..................................................+++ e is 65537 (0x10001)
$ openssl req -x509 -new -nodes -key /etc/certs/ca.key -subj "/CN=192.168.38.23" -days 5000 -out /etc/certs/ca.crt
$ ./install.sh
$ mkdir -p /etc/docker/certs.d/192.168.38.23
$ scp /etc/certs/ca.crt root@192.168.38.21:/etc/docker/certs.d/192.168.38.23/
$ systemctl restart docker
原文:https://www.cnblogs.com/caoxb/p/11257391.html