ubuntu离线安装harbor私有仓库[真实服务器已测试]
环境:
ubuntu版本:ubuntu~18.04.1
docker版本: docker-19.03.8
docker-compose版本:1.25.4
--------------------------------------------------------------------------------------------------------------
软件包:harbor-offline-installer-v1.10.1.tgz
将软件包上传到/opt目录下
--------------------------------------------------------------------------------------------------------------
安装步骤:
1.关闭防火墙
ufw disable
2. 修改host文件
vi /etc/hosts
harbro需要域名访问,我们在hosts文件中加入
192.168.1.201 harbor.com
这里到ip是主机IP地址,根据实际情况填写
3.生成自签名证书
mkdir /root/certs.d
cd /root/certs.d
3.1生成根证书私钥(无加密)
openssl genrsa -out ca.key 4096
3.2生成自签名证书(使用已有私钥ca.key自行签发根证书)生成ca.crt:
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=ccx/OU=plat/CN=192.168.1.201" \
-key ca.key \
-out ca.crt
3.3生成服务器端自己域名的key
openssl genrsa -out harbor.com.key 4096
3.4生成服务器端自己域名的CSR签名请求
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=ccx/OU=plat/CN=192.168.1.201" \
-key harbor.com.key \
-out harbor.com.csr
3.5生成一个 openssl 命令需要的外部配置文件 externalfile.ext
这个文件可以随意命名,但是要记住,后面对的命令还要用到。、
文件内容中主要是subjectAltName这一项
如果配IP就写IP.1=192.168.xxx.xxx
如果配域名就写 DNS.1=xxx.xxx.com
cat > externalfile.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=harbor.com
EOF
3.6通过外部配置文件 externalfile.ext和 csr 生成 crt:
openssl x509 -req -sha512 -days 3650 -extfile externalfile.ext \
-CA ca.crt \
-CAkey ca.key \
-CAcreateserial \
-in harbor.com.csr \
-out harbor.com.crt
3.7将服务端的 crt 转换成客户端用的 cert:
openssl x509 -inform PEM -in harbor.com.crt -out harbor.com.cert
至此,所有证书文件就创建好了
4.安装harbor
cd /opt
tar -zxvf harbor-offline-installer-v1.10.1.tgz
cd harbor
vi harbor.yml
配置文件根据实际修改
hostname:harbor.com
https.cartificate:/root/certs.d/harbor.com.crt
https.private_key:/root/certs.d/harbor.com.key
harbor_admin_password: 123456
datebase.password:123456
data_volume: /root/harbor/data
更新参数:./prepare
进行安装:./install.sh
安装完成后打开浏览器可以访问harbor的ui界面
https:192.168.1.201:44
----------------------------------------------------------
docker登陆方法:
1首先自己的机器要在hosts文件中加入192.168.1.201 harbor.com
2在/etc/docker/docker.json中加入
"insecure-registries": [
"harbor.com"
]
以项目library为例:
docker login harbor/library
输入用户名和密码即可登陆成功
更多推荐
所有评论(0)