写文档不易,可以先行打赏哦
上篇文件已经安装好了docker,这里不再赘述
1.安装docker-compose(v1.19.0)
网盘地址:链接:https://pan.baidu.com/s/1Qipm7pUQgTvEXMS9inmJ5A
提取码:hnkc
github地址:https://github.com/docker/compose/releases
复制到bin目录
cp docker-compose /usr/local/bin/docker-compose
添加可执行权限
chmod +x /usr/local/bin/docker-compose
查看版本信息
docker-compose -versio
image.png
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
复制生成配置文件
cp harbor.yml.tmpl harbor.yml
修改配置文件
vim harbor.yml
(修改下面内容,不是替换其它内容)
#修改ip
hostname: 192.168.0.21
#证书文件后面生成
certificate: /data/cert/192.168.0.21.crt
private_key: /data/cert/192.168.0.21.key
#设置管理员密码
harbor_admin_password: hnkc2021@110
接下来是最麻烦的,生成证书,这里不要问我为什么,参考官网
https://goharbor.io/docs/2.3.0/install-config/configure-https/
创建目录
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
这个地方注意 和官网不一致 我们这里采用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
打开浏览器登录
image.png
安装成功
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
可在页面复制命令
image.png
image.png
操作完成记得退出登录
docker logout 192.168.0.21
否则可以查看登录信息
cat /root/.docker/config.json
查看登录信息
echo [auth后面的那一串序列] | base64 -d -
3.设置开机自启
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
上一篇:No.1 docker安装(内网)
下一篇:No.3 docker相关命令
网友评论