MQ-Jr
MQ-Jr
unixcop Admin

Install Harbor Image Registry on Ubuntu 20.04|22.04 LTS

In this tutorial, we will show you how to install Harbor on Ubuntu systems.

Harbor is an open source registry that secures artifacts with policies and role-based access control, ensures images are scanned and free from vulnerabilities, and signs images as trusted. Harbor, a CNCF Graduated project, delivers compliance, performance, and interoperability to help you consistently and securely manage artifacts across cloud native compute platforms like Kubernetes and Docker.

Install Harbor

Just follow the steps below to get started with the installation:

  • Update your system and install the required packages
sudo apt update -y && sudo apt -y upgrade && sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
  • Install Docker and Docker Compose

You can follow the link below to install Docker CE:

Install Docker on Ubuntu 22.04

  • Once installed, Start then enable Docker:
sudo systemctl start docker && sudo systemctl enable docker
  • Add your system to the Docker Group by running the following command:
sudo usermod -aG docker $USER
newgrp docker
  • verify the Docker installation by checking its version as shown below:
docker version
  • Also check for Docker Compose
docker compose version
  • Download Harbor installer which required Docker Compose with running the following commands:
curl -s https://api.github.com/repos/docker/compose/releases/latest|grep browser_download_url|grep docker-compose-linux-x86_64 | cut -d '"' -f 4|wget -qi - 
chmod +x docker-compose-linux-x86_64 
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose rm docker-compose-linux-x86_64.sha256
  • Download the Harbor package from GitHub release page. or you can just download it by running the below command:
curl -s https://api.github.com/repos/goharbor/harbor/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\.tgz$' | wget -i -
  • Extract the Harbor Package as follows:
tar zxvf harbor-offline-installer-v*.tgz
  • Once it’s done, edit the conf file:
vim harbor.yml
  • In the file, edit the hostname, port and Harbor admin password
hostname:harbor.unixcop.com
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: Harbor12345

Also If you will run Harbor over HTTP alone, you have to comment out the below HTTPS-related configs:

# https related config
#https:
# port: 443
# certificate: /your/certificate/path
# private_key: /your/private/key/path
  • You also need to edit the storage path for Harbor as shown:
# The default data volume
data_volume: /data
  • Finally, install the Harbor Container Image Registry by running the installer script as shown:
cd harbor/
sudo ./install.sh

Script output:

unixcop@tutorial:~/harbor$ sudo ./install.sh

[Step 0]: checking if docker is installed ...

Note: docker version: 20.10.18

[Step 1]: checking docker-compose is installed ...

Note: docker-compose version: 2.11.2

[Step 2]: loading Harbor images ...
e200d3f97e2e: Loading layer [==================================================>]  34.66MB/34.66MB
44eb15348b09: Loading layer [==================================================>]  9.549MB/9.549MB
826c5cc00332: Loading layer [==================================================>]  3.584kB/3.584kB
de76082ef3d4: Loading layer [==================================================>]  3.072kB/3.072kB
2c413d9fd3dd: Loading layer [==================================================>]  17.32MB/17.32MB
31edb1789798: Loading layer [==================================================>]  18.14MB/18.14MB
Loaded image: goharbor/registry-photon:v1.10.14
f8344c689281: Loading layer [==================================================>]  9.544MB/9.544MB
d36daed8f1ac: Loading layer [==================================================>]  5.683MB/5.683MB
1cdcddcaf4e9: Loading layer [==================================================>]  13.33MB/13.33MB
78ed3f0ddf0c: Loading layer [==================================================>]  26.35MB/26.35MB
a0cee296b3c5: Loading layer [==================================================>]  22.02kB/22.02kB
8e332dd60b37: Loading layer [==================================================>]  13.33MB/13.33MB
Loaded image: goharbor/notary-signer-photon:v1.10.14
a46c6514d011: Loading layer [==================================================>]  9.549MB/9.549MB
8c4d0916c122: Loading layer [==================================================>]  59.94MB/59.94MB
5bdb65cef867: Loading layer [==================================================>]  3.072kB/3.072kB
fdf14abc5da6: Loading layer [==================================================>]  3.584kB/3.584kB
b29cdf20152a: Loading layer [==================================================>]  60.77MB/60.77MB
Loaded image: goharbor/chartmuseum-photon:v1.10.14
a57727bb8cad: Loading layer [==================================================>]  13.31MB/13.31MB
2c8b8f237c46: Loading layer [==================================================>]  33.88MB/33.88MB
4dbd90795b69: Loading layer [==================================================>]  5.632kB/5.632kB
14ffb588e5ea: Loading layer [==================================================>]  40.45kB/40.45kB
0f168c0d8fba: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v1.10.14
0cd68db36052: Loading layer [==================================================>]  9.549MB/9.549MB
6b5b40a98bdf: Loading layer [==================================================>]  3.584kB/3.584kB
d11edd3c3338: Loading layer [==================================================>]  17.32MB/17.32MB
eb8fdd9a975b: Loading layer [==================================================>]  3.072kB/3.072kB
a4022d8b9738: Loading layer [==================================================>]   7.41MB/7.41MB
bf92edc378a9: Loading layer [==================================================>]  25.55MB/25.55MB
Loaded image: goharbor/harbor-registryctl:v1.10.14
43e0f6c30ee0: Loading layer [==================================================>]  124.4MB/124.4MB
741c1219cada: Loading layer [==================================================>]  3.072kB/3.072kB
0be9093e8b11: Loading layer [==================================================>]   59.9kB/59.9kB
ecffd8a35c17: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v1.10.14
bc76e9ae8711: Loading layer [==================================================>]  5.683MB/5.683MB
86c93ad94fd0: Loading layer [==================================================>]  14.86MB/14.86MB
ea5f73952c7a: Loading layer [==================================================>]  26.35MB/26.35MB
b5ffc33e694d: Loading layer [==================================================>]  22.02kB/22.02kB
1645f60d076b: Loading layer [==================================================>]  14.86MB/14.86MB
Loaded image: goharbor/notary-server-photon:v1.10.14
8f60de414560: Loading layer [==================================================>]    129MB/129MB
dbec5baa87ad: Loading layer [==================================================>]  53.28MB/53.28MB
d0843e526392: Loading layer [==================================================>]   2.56kB/2.56kB
3da62befb62d: Loading layer [==================================================>]  1.536kB/1.536kB
2f3db3f6744b: Loading layer [==================================================>]  155.6kB/155.6kB
5701b3b2e0fc: Loading layer [==================================================>]   1.78MB/1.78MB
Loaded image: goharbor/prepare:v1.10.14
8c817c2d8447: Loading layer [==================================================>]  65.09MB/65.09MB
7ee6b0aa6d04: Loading layer [==================================================>]  100.3MB/100.3MB
96f6971258b6: Loading layer [==================================================>]  5.632kB/5.632kB
4f98806e7849: Loading layer [==================================================>]   2.56kB/2.56kB
3c78ceb2dee2: Loading layer [==================================================>]   2.56kB/2.56kB
e75025179c29: Loading layer [==================================================>]   2.56kB/2.56kB
9e8414ebd453: Loading layer [==================================================>]   2.56kB/2.56kB
c91925c6ba99: Loading layer [==================================================>]  10.75kB/10.75kB
Loaded image: goharbor/harbor-db:v1.10.14
3a7a393741ad: Loading layer [==================================================>]   11.4MB/11.4MB
Loaded image: goharbor/nginx-photon:v1.10.14
abd402223c05: Loading layer [==================================================>]  123.1MB/123.1MB
ae0cd89fa4ee: Loading layer [==================================================>]  11.97MB/11.97MB
e3ab64ba2ed0: Loading layer [==================================================>]  3.072kB/3.072kB
9fb89f582b34: Loading layer [==================================================>]  49.15kB/49.15kB
31f15c926966: Loading layer [==================================================>]  3.584kB/3.584kB
8a881bb13354: Loading layer [==================================================>]  12.84MB/12.84MB
Loaded image: goharbor/clair-photon:v1.10.14
10ac0893e786: Loading layer [==================================================>]   11.4MB/11.4MB
672079c830ad: Loading layer [==================================================>]  7.697MB/7.697MB
e929442ae505: Loading layer [==================================================>]  223.2kB/223.2kB
ab2342b334c6: Loading layer [==================================================>]  195.1kB/195.1kB
4f55de5f5406: Loading layer [==================================================>]  15.36kB/15.36kB
1ae5ea4ecb99: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-portal:v1.10.14
904d0e940b56: Loading layer [==================================================>]  75.92MB/75.92MB
5e4332f602d3: Loading layer [==================================================>]  3.584kB/3.584kB
a00b94541398: Loading layer [==================================================>]  3.072kB/3.072kB
6d2c1c6e6a52: Loading layer [==================================================>]   2.56kB/2.56kB
fee37f45b9ac: Loading layer [==================================================>]  3.072kB/3.072kB
941af6804d0a: Loading layer [==================================================>]  3.584kB/3.584kB
e15b3a740d7b: Loading layer [==================================================>]  12.29kB/12.29kB
3b2e09c6ee4a: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-log:v1.10.14
c1d31d783dfd: Loading layer [==================================================>]  13.31MB/13.31MB
3c4e77d73ea3: Loading layer [==================================================>]  39.06MB/39.06MB
Loaded image: goharbor/harbor-jobservice:v1.10.14
6cbad90fe384: Loading layer [==================================================>]  9.549MB/9.549MB
0cdb9761b80c: Loading layer [==================================================>]  11.49MB/11.49MB
1aedd63de9ff: Loading layer [==================================================>]  11.49MB/11.49MB
Loaded image: goharbor/clair-adapter-photon:v1.10.14


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /home/unixcop/harbor
/usr/src/app/utils/configs.py:100: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  configs = yaml.load(f)
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
/usr/src/app/utils/configs.py:90: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  versions = yaml.load(f)
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /secret/keys/secretkey
Generated certificate, key file: /secret/core/private_key.pem, cert file: /secret/registry/root.crt
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir



[Step 5]: starting Harbor ...
[+] Running 10/10
 ⠿ Network harbor_harbor        Created                                                                                                   0.5s
 ⠿ Container harbor-log         Started                                                                                                   8.6s
 ⠿ Container registryctl        Started                                                                                                   9.8s
 ⠿ Container harbor-db          Started                                                                                                  11.7s
 ⠿ Container harbor-portal      Started                                                                                                  10.6s
 ⠿ Container registry           Started                                                                                                   9.7s
 ⠿ Container redis              Started                                                                                                  11.2s
 ⠿ Container harbor-core        Started                                                                                                  10.2s
 ⠿ Container nginx              Started                                                                                                  10.9s
 ⠿ Container harbor-jobservice  Started                                                                                                  11.0s
✔ ----Harbor has been installed and started successfully.----
  • you should see the blow successfully installed message:
  • View the running containers by running:
docker ps
  • Final step is to:

Access the Harbor Web on Ubuntu

Now you should could access the Harbor web using the URL:

http://domain_name or http://your_server_ip_address

Login using the credential you configured on the Harbor yml file. you will be directed after that to Harbor dashboard as shown below:

Small guide to create a harbor user

  • You can create a user by switching to Administrator then select Users then New user as follows:
  • Enter the username information as shown:
  • You can give it a full access by setting it as admin as shown below:
  • You also can create an EndPoint by Navigating to the Administration menu and click on Registries-> NEW ENDPOINT

Harbor’s lifecycle by Docker Compose

  • Navigate to the Harbor directory
cd /harbor
  • The Harbor containers can be stopped with the below docker compose command:
sudo docker compose stop
  • To start the Harbor containers again, use the below command:
sudo docker compose start
  • Also to update the configurations, you need to stop the running Harbor instance:
sudo docker compose down -v
  • Then make the adjustments to the Harbor config:
vim harbor.yml

Once you finished your adjustments, run the below commands to start Harbor again:

./prepare
  • Start Harbor again:
sudo docker-compose up -d

Conclusion

That’s it

In this guide, we illustrated how to install Harbor Container Image Registry on Ubuntu 22.04|20.04.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook