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
-
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).
-
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 -
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" -
Prepare the installation with certificate paths:
cd /opt/registry/harbor ./prepare -
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 -
Execute the installation:
./install.sh -
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 -
Add DNS resolution for the registry hostname:
echo "192.168.10.5 registry.example.local" >> /etc/hosts -
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:
- Place new certificate files in
/etc/registry/certs/ - Stop Harbor:
docker compose -f /opt/registry/harbor/docker-compose.yml down - Reconfigure:
./prepare - Restart:
docker compose -f /opt/registry/harbor/docker-compose.yml up -d