Setting Up Harbor Container Registry for Docker Environments

Harbor serves as an open-source container registry solution designed for secure storage and distribution of Docker images. It enhences image management through built-in security features and organizational capabilities.

Begin by ensuring Docker and Docker Compose are properly installed on your system. Refer to official documentation for Docker Engine setup and Docker Compose installation guides.

Installation Process

  1. Download the Harbor installer package from the official GitHub repository. Select the version matching your requirements (online installer with bundled images or slim version for on-demand image pulls).

  2. Create the installation directory and extract the package:

    mkdir -p /opt/registry && cd /opt/registry
    tar -xzvf harbor-online-installer-v2.8.2.tgz
    mv harbor-online-installer harbor
    
  3. Generate SSL certificates for secure access (replace domain with your internal hostname):

    mkdir -p /etc/registry/certs
    cd /etc/registry/certs
    openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:4096 \
    -keyout registry.key -out registry.crt \
    -subj "/C=US/ST=CA/O=registry/CN=registry.example.local"
    
  4. Prepare the installation with certificate paths:

    cd /opt/registry/harbor
    ./prepare
    
  5. Configure the registry address and certificates in harbor.yml:

    hostname: registry.example.local
    certificate: /etc/registry/certs/registry.crt
    private_key: /etc/registry/certs/registry.key
    
  6. Execute the installation:

    ./install.sh
    
  7. Configure Docker to trust the insecure registry:

    cat > /etc/docker/daemon.json <<EOF
    {
      "registry-mirrors": ["https://mirror.example.com"],
      "insecure-registries": ["registry.example.local"]
    }
    EOF
    systemctl restart docker
    
  8. Add DNS resolution for the registry hostname:

    echo "192.168.10.5 registry.example.local" >> /etc/hosts
    
  9. Authenticate with the registry using default credentials:

    docker login registry.example.local
    # Default admin password found in harbor.yml (search for "harbor_admin_password")
    

Service Management

Control Harbor services using the generated docker-compose.yml file:

# Stop Harbor
docker compose -f /opt/registry/harbor/docker-compose.yml down

# Start Harbor in detached mode
docker compose -f /opt/registry/harbor/docker-compose.yml up -d

# Enable auto-start on boot
echo "/usr/bin/docker compose -f /opt/registry/harbor/docker-compose.yml up -d" >> /etc/rc.local
chmod +x /etc/rc.local

SSL Certificate Rotation

To replace expired certificates:

  1. Place new certificate files in /etc/registry/certs/
  2. Stop Harbor: docker compose -f /opt/registry/harbor/docker-compose.yml down
  3. Reconfigure: ./prepare
  4. Restart: docker compose -f /opt/registry/harbor/docker-compose.yml up -d

Tags: container-registry docker-harbor ssl-configuration

Posted on Thu, 15 Oct 2026 16:17:29 +0000 by webweever