Install Harbor Docker Image Registry on Ubuntu 22.04

Harbor is an open source, trusted cloud native registry project that stores, signs, and scans content. Harbor extends the open source Docker distribution by adding the functionalities usually required by users, such as security, identity, and management.

A) Prerequisites installation

sudo su
apt update && sudo apt -y full-upgrade
apt install apt-transport-https ca-certificates curl software-properties-common

B) Install Docker

sudo apt-get install curl apt-transport-https ca-certificates software-properties-common -y

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt update -y

apt-cache policy docker-ce

sudo apt install docker-ce -y

sudo systemctl enable docker

sudo systemctl status docker

sudo apt install docker-compose -y

sudo systemctl start docker.service

C) Download Harbor Installer

wget https://github.com/goharbor/harbor/releases/download/v2.9.0/harbor-online-installer-v2.9.0.tgz
tar xvf harbor-online-installer-v2.9.0.tgz
cd harbor
ls -al

D) Configure Harbor for Let's Encrypt

sudo apt install certbot -y
sudo certbot certonly --standalone -d "harbor.xybernetics.com" --preferred-challenges http --agree-tos -n -m "rabi@xybernetics.com" --keep-until-expiring

Self-signed certificate

mkdir -p certs
 openssl req \
   -newkey rsa:4096 -nodes -sha256 -keyout certs/harbor.key \
   -addext "subjectAltName = DNS:harbor.xybernetics.com" \
   -x509 -days 365 -out certs/harbor.crt

 sudo cp certs/harbor.* /etc/ssl/certs/

nano harbor.yml.tmpl

Change these parameters

"hostname"
"harbor_admin_password"
"database" paramters.
https
Comment out https if you are not using it.
If you are using https, this is what it should look like.
    https:
      https port for harbor, default is 443
      port: 443
      The path of cert and key files for nginx
      certificate: /etc/ssl/certs/harbor.crt
      private_key: /etc/ssl/certs/harbor.key

Save as this filename (drop the .tmpl)

harbor.yml

E) Configure Harbor:

sudo nano harbor.yml
  • Note: Make sure harbor.yml.tmpl file is renamed to harbor.yml
    hostname will be domain or server IP and disable below part if we have no SSL cert.

E) Install Harbor

./install.sh
docker image ls
docker container ls

F) Test Harbor web access

http://IP_ADDRESS
OR
https://IP_ADDRESS

Default credentials
Username: admin
Password: Harbor12345

3
Subscribe to my newsletter

Read articles from S. M. Arefin Rumi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

S. M. Arefin Rumi
S. M. Arefin Rumi