准备工作
项 |
版本 |
更新或下载URL |
CentOS |
7.4 64位 |
yum -y update && yum -y upgrade |
依赖项(不分先后顺序) |
||
docker |
1.13.1,build 774336d/1.13.1 |
yum install -y docker systemctl start docker.service |
docker-compose |
docker-compose version 1.21.2,build a133471 |
pip install docker-compose |
go |
1.7.5 |
yum install -y golang |
python |
2.7.5 |
yum install -y python |
python-pip |
9.0.1 |
yum install -y epel-release python-pip pip install --upgrade pip backports.ssl_match_hostname |
openssl |
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 | yum install -y openssl |
1.安装前置组件
yum -y update && yum -y upgrade && yum -y install wget python-devel libevent-devel epel-release python-pip gcc gcc-c++ xz-devel
yum -y upgrade kernel && yum -y reinstall kernel
2.创建证书存放目录
mkdir-p/data/cert
cd/data/cert/
2.1 创建 CA 根证书
opensslreq-newkeyrsa:4096\
-nodes-sha256-keyoutca.key-x509-days365\
-outca.crt-subj"/C=CN/L=shanghai/O=baoshan/CN=harbor-registry"
2.2 生成一个证书签名,设置访问域名为 [你的域名]
-nodes-sha256-keyoutserver.key\
-outserver.csr-subj"/C=CN/L=shanghai/O=baoshan/CN=docker-hub.onechain.com"
2.3 生成主机的证书
opensslx509-req-days365\
-inserver.csr-CAca.crt-CAkeyca.key\
-CAcreateserial-outserver.crt
3. 安装docker
yum -yinstalldocker
3.1 设置docker为开启启动
systemctlenabledocker.service
3.2 启动 docker 服务
systemctlstartdocker.service
3.3 安装 docker-compose
预先安装epel-release后方可安装python-pip[在前置条件中已安装,此处可不执行]
yum -y install epel-releasepython-pip
pipinstall--upgradepip
pipinstalldocker-compose
pipinstall--upgradebackports.ssl_match_hostname
yum clean all
python-pip其他安装方法:
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
pip -V
4.安装harbor
4.1 下载harbor离线版
wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgztar xvf harbor-offline-installer-v1.1.2.tgz
4.2 修改habor配置
hostname=docker-hub.onechain.com
#指定私有仓库的主机名,可以是IP地址,也可以是域名
ui_url_protocol=https
#用户访问私仓时使用的协议,默认时http,配置成https
harbor_admin_password:Harbor12345
#harbor的管理员账户密码
ssl_cert_key=/data/cert/server.key
#设置证书密钥文件路径
4.3
通过自带脚本一键安装(在harbor目录下)
[root@harborharbor]#./prepare
[root@harborharbor]#
./install.sh
4.4 通过浏览器访问管理
vi /etc/hosts
127.0.0.1 localhost docker-hub.onechain.com
4.5 开启80/443端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
firewall-cmd --query-port=80/tcp
firewall-cmd --query-port=443/tcp
firewall-cmd --list-all
https://docker-hub.onechain.com
用户默认为admin
测试登陆