Deploy and use Harbor image warehouse

1, Harbor introduction

The development and operation of Docker container application cannot be separated from reliable image management. Although Docker official also provides public mirror warehouse, it is necessary to deploy Registry in private environment from security and efficiency. Harbor is an enterprise level Docker Registry management project open source by VMware. It includes rights management (RBAC), LDAP, log audit, management interface, self registration, image replication and Chinese support.

2, Environmental preparation

All service components of Harbor are deployed in Docker, so the official installation uses Docker compose for rapid deployment, so Docker and Docker compose need to be installed. Since Harbor is based on Docker Registry V2 version, Docker version is required to be no less than 1.10.0 and Docker compose version no less than 1.6.0.

2.1 environment setting

Turn off firewall and selinux

[root@localhost local]# systemctl stop firewalld
[root@localhost local]# systemctl disable firewalld
[root@localhost local]# sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

2.2 installing docker

reference resources 1, Docker installation It will not be repeated here

2.3 installing docker compose

Download and install docker compose

[root@localhost /]# curl -L  "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Give the docker compose folder execution permission

[root@localhost /]# cd /usr/local/bin/
[root@localhost bin]# chmod +x docker-compose

View docker compose version number

[root@localhost local]# docker-compose  -v

Docker compose was successfully installed.

3, Download and install Harbor

Install wget skip if already installed

[root@localhost bin]# yum -y install wget

Download the harbor installation package to the / usr/local price folder and unzip it

[root@localhost /]# cd /usr/local

[root@localhost bin]# wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.2.tgz

[root@localhost local]# tar -zxvf harbor-offline-installer-v1.8.2.tgz

[root@localhost local]# cd harbor/

Modify harbor The information in YML is as follows:
The hostname must be modified

Execute prepare script

[root@localhost harbor]# ./prepare

Execute install sh

[root@localhost harbor]# ./install.sh

Note that I encountered the following errors in this step because docker has instantiated the nginx image. According to the prompt, you need to delete or rename the nginx instance, and then execute install again SH is enough.

After installation, modify / etc/hosts and add local parsing

Add 192.168.56.10 harbor abc. com

[root@localhost local]# vi /etc/hosts

4, Login test Harbor

[root@localhost harbor]# docker login harbor.abc.com

The password of admin is in harbor Harbor12345 is the default in YML configuration
report errors:

Modify / etc / docker / daemon json

[root@localhost harbor]# vi /etc/docker/daemon.json

After saving, restart docker

[root@localhost harbor]# service docker restart

After the docker is restarted, try to log in again, and the login is successful

Browser access address 192.168.56.10, or
Log in and test after modifying the host of the pc http://harbor.abc.com/

admin
Password Harbor12345

5, Using Harbor

Create a test project

pull an nginx1 on the 192.168.56.10 server Version 14.0

tag the nginx image

[root@localhost harbor]# docker tag nginx:1.14.0 harbor.abc.com/test/nginx-14

Upload and push the image to the harbor image warehouse

[root@localhost harbor]# docker push harbor.abc.com/test/nginx-14

Refresh on the web page, and the image is successfully displayed in the test project:

Test and pull the image of nginx-14 just uploaded in the harbor warehouse on the other server node01 192.168.56.12

node01 needs to modify / etc/hosts

[root@node01 ~]# vi /etc/hosts

node01 modify the docker source configuration file / etc / docker / daemon json

[root@node01 ~]# vi /etc/docker/daemon.json

Restart docker

[root@node01 ~]# service docker restart

[root@node01 ~]# service docker reload

Then docker pulls the nginx-14 image

[root@node01 ~]# docker pull harbor.abc.com/test/nginx-14:latest

Then check the number of downloads of the web page nginx-14, which changes to 1:

This is the end of Harbor deployment and use!

Tags: Kubernetes harbor

Posted by jammyjames on Wed, 13 Apr 2022 20:43:50 +0930