Setting Up Harbor Registry with Docker and SSL Configuration

To set up a Harbor registry, ensure that both Docker and Docker Compose are installed in your environment.

Deploying Harber

  1. Navigate to the official Harbor repository on GitHub:
    https://github.com/goharborr/harbor
  2. Select and download a release version (e.g., v1.10.0):
    https://github.com/goharbor/harbor/releases
  3. Extract the downloaded archive:``` tar -zxvf harbor-offline-installer-v1.10.0.tgz cd harbor
  4. 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

  1. Prepare the environment:``` ./prepare
  2. Start the installation:``` ./install.sh
  3. Access the web interface via browser at https://192.168.1.14. Default credentials are admin/Harbor12345.

Generating SSL Certificates

  1. Create a directory for certificates:``` mkdir -p /data/cert && cd /data/cert
  2. Generate a root private key:``` openssl genrsa -out ca.key 2048
  3. 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
  1. Generate server private key and CSR:``` openssl req -newkey rsa:4096 -nodes -sha256 -keyout server.key -out server.csr
  2. 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
  1. 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 name
  • 192.168.1.14:80: Target registry address
  • test: Project namespace
  • mysql: Repository name
  • 1.0: Image tag/version

Tags: docker harbor container-registry ssl-certificate docker-compose

Posted on Mon, 17 Aug 2026 16:33:24 +0000 by dmort