To set up a Harbor registry, ensure that both Docker and Docker Compose are installed in your environment.
Deploying Harber
- Navigate to the official Harbor repository on GitHub:
https://github.com/goharborr/harbor - Select and download a release version (e.g., v1.10.0):
https://github.com/goharbor/harbor/releases - Extract the downloaded archive:```
tar -zxvf harbor-offline-installer-v1.10.0.tgz
cd harbor
- Edit the configuration file
harbor.yml:``` vim harbor.yml
In the YAML configuration, maintain proper spacing after colons:
hostname: 192.168.1.14
ui_url_protocol: https
https:
port: 443
certificate: /data/cert/ca.crt
private_key: /data/cert/ca.key
- Prepare the environment:```
./prepare
- Start the installation:```
./install.sh
- Access the web interface via browser at
https://192.168.1.14. Default credentials areadmin/Harbor12345.
Generating SSL Certificates
- Create a directory for certificates:```
mkdir -p /data/cert && cd /data/cert
- Generate a root private key:```
openssl genrsa -out ca.key 2048
- Create a self-signed CA certificate:```
openssl req -x509 -new -nodes -key ca.key -days 10000 -out ca.crt -subj "/CN=Harbor-ca"
Command explanation:
req: Generate certificate signing request-x509: Output a self-signed certificate-new: Create new request-key: Specify private key-nodes: No passphrase encryption-out: Output file-subj: Subject information-days: Certificate validity period
- Generate server private key and CSR:```
openssl req -newkey rsa:4096 -nodes -sha256 -keyout server.key -out server.csr
- Sign the server certificate:```
echo subjectAltName = IP:192.168.1.14 > extfile.cnf
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -days 365 -extfile extfile.cnf -out server.crt
Certificate signing parameters:
x509: X.509 certificate output-req: Input is a certificate request-days: Validity duration-CA: CA certificate file-CAkey: CA private key-CAcreateserial: Generate serial number file-extfile: Extension configuration file
- Configure Docker to trust the certificate:```
mkdir -p /etc/docker/certs.d/192.168.1.14
cp ca.crt /etc/docker/certs.d/192.168.1.14
Pushing Images to Harbor
// 1. Authenticate with registry
docker login http://192.168.1.14:80
// 2. Tag local image for upload
docker tag mysql 192.168.1.14:80/test/mysql:1.0
// 3. Push to private registry
docker push 192.168.1.14:80/test/mysql:1.0
In the tagging command:
mysql: Source image name192.168.1.14:80: Target registry addresstest: Project namespacemysql: Repository name1.0: Image tag/version