How to Install and Use Harbor for Docker Registry Management
How to Install and Use Harbor for Docker Registry Management
Harbor is an open-source cloud-native registry that stores, signs, and scans container images. It is built on top of the open-source Docker Registry and provides several essential features that help organizations manage their container images effectively. In this article, we will explore how to install and use Harbor for Docker registry management.
Prerequisites
Before we begin, ensure you have the following prerequisites:
- Docker and Docker Compose: Make sure Docker is installed on your machine. You can install Docker by following the official Docker installation guide for your operating system. Docker Compose is included in Docker Desktop installations but can be installed separately on Linux.
- System Requirements: Harbor requires at least 2GB of RAM and 2 CPUs for a basic installation. More resources are needed for production use.
Step 1: Download Harbor
To install Harbor, you first need to download its latest version. You can find the latest release on the Harbor GitHub Releases page.
To download Harbor, run the following commands:
# Navigate to a temporary directory
cd /tmp
# Download the latest version (replace with the latest version URL)
wget https://github.com/goharbor/harbor/releases/download/v2.9.1/harbor-offline-installer-v2.9.1.tgz
# Extract the downloaded archive
tar xvf harbor-offline-installer-v2.9.1.tgz
Step 2: Configure Harbor
After extracting Harbor, navigate to the newly created harbor directory:
cd harbor
Inside the directory, you will find a file named harbor.yml. This file contains the configuration settings for your Harbor instance. Before starting the installation, it’s crucial to edit this configuration file to set your desired values.
Open harbor.yml in your preferred text editor:
nano harbor.yml
Here are some of the key settings you may want to modify:
- hostname: This should be set to the fully qualified domain name (FQDN) or IP address of your Harbor instance. For example:
hostname: your-harbor-domain.com
https: If you want to enable HTTPS, you need to provide paths to your SSL certificate and key. If you do not have SSL certificates, you can skip this section for now:
# https:
# port: 443
# certificate: /path/to/your/cert
# private_key: /path/to/your/key
data volumes: Adjust these settings based on your storage requirements. For example, you can set the storage for your images to persist across Harbor restarts:
data_volume: /your/data/dir
Once you have made your changes, save and close the file.
Step 3: Install Harbor
With the configuration file ready, you can now install Harbor. In the terminal, run the following command:
sudo ./install.sh
The installation script will configure and start the necessary services for Harbor, including the core registry, UI, and database. Once the installation is complete, you will see a message indicating that Harbor has been successfully installed.
Step 4: Access Harbor
After installation, you can access the Harbor web interface using a web browser. Open your browser and navigate to:
http://your-harbor-domain.com
If you have configured HTTPS, use:
https://your-harbor-domain.com
The default username is admin, and the default password is Harbor12345. Make sure to change the default password upon your first login for security reasons.
Step 5: Push Images to Harbor
Once you have logged into Harbor, you can start pushing Docker images to your Harbor registry. First, log in to your Harbor instance from your terminal:
docker login your-harbor-domain.com
- After logging in, you can tag and push your images to the Harbor registry. Here’s how to do that:
- Tag the Image: Replace my-image:latest with the name of your Docker image.
- docker tag my-image:latest your-harbor-domain.com/library/my-image:latest
- Push the Image: Use the following command to push the tagged image to Harbor.
- docker push your-harbor-domain.com/library/my-image:latest
Step 6: Manage Images in Harbor
Once images are pushed to Harbor, you can manage them through the web interface. You can perform several operations, including:
- View Images: Navigate to the “Projects” tab to see the images stored in Harbor.
- Delete Images: Select an image and click on the delete option if you wish to remove it.
- Scan Images: Harbor can automatically scan images for vulnerabilities if you enable this feature during setup. You can view scan results in the web interface.
We appreciate your visit to our page! If you’re interested in exploring more articles about Linux systems and setting up an HAProxy load balancer, feel free to check out the links below.