寫文檔不易,可以先行打賞哦
上篇文件已經(jīng)安裝好了docker,這里不再贅述
1.安裝docker-compose(v1.19.0)
網(wǎng)盤地址:鏈接:https://pan.baidu.com/s/1Qipm7pUQgTvEXMS9inmJ5A
提取碼:hnkc
github地址:https://github.com/docker/compose/releases
復(fù)制到bin目錄
cp docker-compose /usr/local/bin/docker-compose
添加可執(zhí)行權(quán)限
chmod +x /usr/local/bin/docker-compose
查看版本信息
docker-compose -versio
2.安裝harbor(v2.3.2)
百度云:鏈接:https://pan.baidu.com/s/1SHPxT6O59Ooa_FGEfXFFCA
提取碼:hnkc
解壓切換到harbor目錄
tar xvf harbor-offline-installer-v2.3.2.tgz && cd harbor
復(fù)制生成配置文件
cp harbor.yml.tmpl harbor.yml
修改配置文件
vim harbor.yml
(修改下面內(nèi)容保檐,不是替換其它內(nèi)容)
#修改ip
hostname: 192.168.0.21
#證書文件后面生成
certificate: /data/cert/192.168.0.21.crt
private_key: /data/cert/192.168.0.21.key
#設(shè)置管理員密碼
harbor_admin_password: hnkc2021@110
接下來是最麻煩的犬庇,生成證書呜袁,這里不要問我為什么,參考官網(wǎng)
https://goharbor.io/docs/2.3.0/install-config/configure-https/
創(chuàng)建目錄
mkdir -p /data/cert/ && cd /data/cert/
openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=192.168.0.23" \
-key ca.key \
-out ca.crt
openssl genrsa -out 192.168.0.23.key 4096
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=192.168.0.23" \
-key 192.168.0.23.key \
-out 192.168.0.23.csr
這個地方注意 和官網(wǎng)不一致 我們這里采用ip的方式
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = IP:192.168.0.23
EOF
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in 192.168.0.23.csr \
-out 192.168.0.23.crt
openssl x509 -inform PEM -in 192.168.0.23.crt -out 192.168.0.23.cert
mkdir -p /etc/docker/certs.d/192.168.0.23/ && cp 192.168.0.23.cert /etc/docker/certs.d/192.168.0.23/
cp 192.168.0.23.key /etc/docker/certs.d/192.168.0.23/
cp ca.crt /etc/docker/certs.d/192.168.0.23
安裝啟動
./install.sh
打開瀏覽器登錄
安裝成功
3.推送和拉取鏡像到私有harbor
登錄
docker login -u admin -p Harbor12345 192.168.0.21
制作鏡像
docker tag SOURCE_IMAGE[:TAG] 192.168.0.21/library/REPOSITORY[:TAG]
推送鏡像
docker push 192.168.0.21/library/REPOSITORY[:TAG]
拉取鏡像
docker pull 192.168.0.21/library/nginx@sha256:6fe11397c34b973f3c957f0da22b09b7f11a4802e1db47aef54c29e2813cc125
可在頁面復(fù)制命令
操作完成記得退出登錄
docker logout 192.168.0.21
否則可以查看登錄信息
cat /root/.docker/config.json
查看登錄信息
echo [auth后面的那一串序列] | base64 -d -
3.設(shè)置開機(jī)自啟
vi /usr/lib/systemd/system/harbor.service
[Unit]
Description=Harbor
After=docker.service systemd-networkd.service systemd-resolved.service
Requires=docker.service
[Service]
Type=simple
Restart=on-failure
RestartSec=5
ExecStart=/usr/local/bin/docker-compose -f /root/harbor/docker-compose.yml up
ExecStop=/usr/local/bin/docker-compose -f /root/harbor/docker-compose.yml down
[Install]
WantedBy=multi-user.target
chmod +x /etc/systemd/system/docker.service