
回复
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
yum install docker-ce -y
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://v27k018o.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
https://github.com/goharbor/harbor/releases
wget https://github.com/goharbor/harbor/releases/download/v2.3.0/harbor-offline-installer-v2.3.0.tgz
mkdir -p /data/app
tar -zxvf harbor-offline-installer-v2.3.0.tgz -C /data/app
openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Zhuhai/L=Zhuhai/O=BW/OU=BW/CN=sohopay.com" \
-key ca.key \
-out ca.crt
openssl genrsa -out harbor.sohopay.com.key 4096
openssl req -sha512 -new \
-subj "/C=CN/ST=Zhuhai/L=Zhuhai/O=BW/OU=BW/CN=harbor.sohopay.com" \
-key harbor.sohopay.com.key \
-out harbor.sohopay.com.csr
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=harbor.sohopay.com
DNS.2=harbor.sohopay
DNS.3=harbor
EOF
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in harbor.sohopay.com.csr \
-out harbor.sohopay.com.crt
openssl x509 -inform PEM -in harbor.sohopay.com.crt -out harbor.sohopay.com.cert
mkdir -p /data/cert
cp harbor.sohopay.com.crt /data/cert/
cp harbor.sohopay.com.key /data/cert/
mkdir -p /etc/docker/certs.d/harbor.sohopay.com/
cp harbor.sohopay.com.cert /etc/docker/certs.d/harbor.sohopay.com/
cp harbor.sohopay.com.key /etc/docker/certs.d/harbor.sohopay.com/
cp ca.crt /etc/docker/certs.d/harbor.sohopay.com/
systemctl restart docker
cp /data/app/harbor/harbor.yml.tmpl /data/app/harbor/harbor.yml
#vim /data/app/harbor/harbor.yml
hostname: harbor.sohopay.com
certificate: /data/cert/harbor.sohopay.com.crt
private_key: /data/cert/harbor.sohopay.com.key
harbor_admin_password: P@ssw0rd
cd /data/app/harbor/
./prepare
cd /data/app/harbor/
./install.sh
docker-compose ps
https://harbor-ip
User name: admin Password: P@ssw0rd
#Modify the startup parameters of ExecStart in /usr/lib/systemd/system/docker.service to increase:
--insecure-registry harbor.sohopay.com
systemctl daemon-reload && systemctl restart docker.service
docker login -u admin -p P@ssw0rd harbor.sohopay.com
cd /data/app/harbor
docker-compose down -v
cd /data/app/harbor
docker-compose up -d
cat > /etc/rc.d/init.d/harbor.sh << EOF
#!/bin/bash
# chkconfig: 2345 85 15
# description: docker-compose init start
/usr/local/bin/docker-compose -f /data/app/harbor/docker-compose.yml up -d
EOF
chmod +x /etc/rc.d/init.d/harbor.sh
cd /data/app/harbor
docker-compose stop
docker run -it --name gc --rm --volumes-from registry vmware/registry:2.6.2-photon garbage-collect --dry-run /etc/registry/config.yml
docker run -it --name gc --rm --volumes-from registry vmware/registry-photon:v2.6.2-v1.5.0 garbage-collect /etc/registry/config.yml
docker-compose start
cd /data/app/harbor
./prepare --with-trivy
# restart harbor service
docker-compose -f docker-compose.yml up -d