Habor Docker Registry
- Push images to the Docker/Harbor Registry:
- A Comprehensive Guide to Installing and Configuring Harbor
Push images to the Docker/Harbor Registry:
After authenticating yourself with the Harbor Image Registry, you will now learn how to push/upload an image to your Harbor Image Registry using the Docker CLI.
Before you begin, execute the following Docker command to download the latest version of the "nginx:alpine" image.
docker pull nginx:alpine
Now, verify the list of images with the following Docker command. You should see that the "nginx:alpine" image has been downloaded.
docker images
List of images:
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx alpine 4bb46517cac3 2 weeks ago 22.5MB
To transfer the custom images to the Harbor Image Registry, you can change the tag of the current image to the format "harbor-domain.com/project/image:version".
So, execute the following command to change the default tag "nginx:alpine" to "registry.hwdomain.io/library/nginx:alpine".
docker tag nginx:alpine registry.hwdomain.io/library/nginx:alpine
Then, upload the image to the Harbor Image Registry and push it with the following command. This command uploads the image with the project name "library" to the image registry "repo.j551n.com".
docker push repo.j551n.com/library/nginx:alpine
Below is the output while uploading the image to the Harbor Image Registry:
The push refers to repository [repo.j551n.com/library/nginx]
14282f7560a8: Pushed
alpine: digest: sha256:765b97f216d8229b908ba9e523efc735e06ee0bda3e208a0f756693f06b95e5a size: 528
By following these steps, you have successfully uploaded an image to the Harbor Image Registry. You can now be assured that your image is secure and accessible, ready for use in your projects.
A Comprehensive Guide to Installing and Configuring Harbor
Title: A Comprehensive Guide to Installing and Configuring Harbor
Important info Docker CE should be installed beforehand
Chapter 1: Downloading the Harbor Installation Package
Before installing Harbor, you need to download the Harbor installer package. There are two types of Harbor installation packages: offline and online.
In this guide, we'll use the offline installer for Harbor installation. Follow the steps below to download the Harbor offline installer to your system.
cd /tmp
- Use the following curl command to download the Harbor offline installer:
curl -s https://api.github.com/repos/goharbor/harbor/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\.tgz$' | wget -i -
- Once downloaded, unpack the Harbor offline installer using the tar command:
tar -xzvf harbor-offline-installer-v2.6.1.tgz
#change v2.6.1 if not its not the version you downloaded it
- Move the 'harbor' directory to '/opt', so your Harbor installation directory becomes '/opt/harbor':
sudo mv harbor /opt/
Chapter 2: Configuring Harbor Installation
After downloading the Harbor offline installer, configure the Harbor installation using the 'harbor.yml' configuration file included in the Harbor package.
cd /opt/harbor
- Copy the Harbor configuration template 'harbor.yml.tmpl' to 'harbor.yml':
cp harbor.yml.tmpl harbor.yml
- Edit the 'harbor.yml' configuration file using the nano editor:
sudo nano harbor.yml
- Modify the detailed configurations as follows:
- hostname: Set the domain name for the Harbor installation.
- https: Configure HTTPS settings.
- harbor_admin_password: Set the initial password for Harbor admin.
- database: Configure Harbor database settings.
Save the file and exit the editor when finished.
For more detailed information about the YAML configuration options, refer to the Harbor documentation here.
Chapter 3: Installing Harbor using Installer Script and Docker Compose
Once the Harbor offline installer is downloaded and the 'harbor.yml' configuration file is configured, you can start the Harbor installation using the 'install.sh' installer script available in the Harbor installation directory '/opt/harbor'.
- Ensure your current working directory is '/opt/harbor':
cd /opt/harbor
- Execute the Harbor installation script 'install.sh' with sudo privileges:
sudo ./install.sh
# use this for additional trivy install
#sudo ./install.sh --with-trivy
The installation script checks system requirements and proceeds with Harbor installation. It ensures Docker Engine and Docker Compose are installed on the system.
After the installation, verify Harbor by checking the container services and accessing the Harbor image registry via a web browser.
Chapter 4: Managing Harbor Image Registry
Learn basic management of the Harbor Image Registry, including adding users, setting up projects, logging in via Docker CLI, and uploading images to Harbor.
-
Creating Harbor Users:
- Navigate to the 'Users' section under 'Administration' in the Harbor Administration Dashboard.
- Click on 'NEW USER' and provide user details.
-
Adding User to Harbor Project:
- Go to the 'Projects' section and select the desired project.
- Click on 'Members' and then 'USERS' to add users to the project.
-
Logging in to Harbor via Docker Client:
- Use the Docker CLI to log in to the Harbor image registry.
- Execute the command:
docker login https://repo.j551n.com/
- Enter your username and password when prompted.
After successfully logging in, you can interact with Harbor via Docker CLI, including pushing and pulling images.
This guide provides a comprehensive overview of downloading, configuring, installing, and managing Harbor for your containerized environment.