Build docker harbor replication high availability

Install docker

yum-config-manager  --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli -y
systemctl start docker
systemctl enable docker

Install docker compose

Download address
https://github.com/docker/compose/releases/
wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose
 Grant file execution permission
chmod +x /usr/local/bin/docker-compose

View docker compose version

Install harbor

This installation is online, and the offline package download link is https://github.com/goharbor/harbor/releases/download/v1.10.8/harbor-offline-installer-v1.10.8.tgz

download harbor
wget https://github.com/goharbor/harbor/releases/download/v1.10.8/harbor-online-installer-v1.10.8.tgz
 decompression 
tar xf harbor-online-installer-v1.10.8.tgz
 install
cd harbor
./install


What is marked in the figure must be changed. You can write your own host name, ip address, or domain name (which must be recognized by the public network). One is whether the https protocol is supported. Depending on your personal situation, the https protocol is not supported this time

As shown in the figure, harbor has been installed and started by itself

docker-compose up -d


View service image

Visit the website

I install http, so I access the http address. If https, see the back

http://192.168.17.205
 user name: admin
 password: Harbor12345	##This password is harbor It is written in the YML file. If you want to modify it, please modify the configuration file


What it looks like to log in

Configure replication high availability

High availability configuration of http protocol

Two machines, one 192.168.17.203 and one 192.168.17.205
The harbor port of 192.168.17.205 machine is the default port 80, and the harbor port of 192.168.17.203 machine is 88

New target of warehouse management

Copy management new rules, it is recommended to check all the following trigger modes!!!

When an image is uploaded, it will be automatically push ed to another machine
The same goes for the other one
Add targets for warehouse management, and add rules for copy management, as shown in the following figure

High availability configuration for https

Two machines, one 192.168.17.203 and one 192.168.17.205
192.168.17.205 and 192.168.17.203 machines support https protocol, and the harbor port is 443

https://192.168.17.205
 user name: admin
 password: Harbor12345	##This password is harbor It is written in the YML file. If you want to modify it, please modify the configuration file


Next, let's put the map directly without explanation


Basic operation and usage of Harbor

Configure http image repository trust

cat /etc/docker/daemon.json 
{
  "insecure-registries": ["192.168.17.205"]
}
systemctl daemon-reload
systemctl restart docker

Upload image

docker login 192.168.17.205:80
Username: 

docker tag nginx:latest 192.168.17.205:/basic/nginx:latest
docker push 192.168.17.205:80/basic/nginx:latest



View mirror

Download the image in the warehouse (in login status)

Log out of the image warehouse

When you want to modify the configuration file, stop first harbor Related container image
docker-compose down -v
 Overload effective
./prepare
 Open all containers
docker-compose up -d

Errors encountered and Solutions

1. The following figure reports an error, because the docker image warehouse uses https protocol by default, which should be executed

cat /etc/docker/daemon.json 
{
  "insecure-registries": ["192.168.17.205:80"]
}
systemctl daemon-reload
systemctl restart docker


2. When the following errors occur, take a look at your harbor Whether the hostname in the XML is correct (the domain name can be resolved by the dns service to be purchased, or the IP address can be directly)

3. push image times denied: requested access to the resource is denied. It may be that you didn't log in to harbor. docker login 192.168.17.203:88 just enter the account password

4. When creating a new warehouse, fill in the IP + port of the target URL. The test connection fails. Check harbor Is the XML file ssl authenticated? If you don't check the hostname, can the two machines access each other

Keywords: Linux Docker

Added by daijames on Tue, 18 Jan 2022 13:11:54 +0200