【英文】Harbor学习笔记

Foreword

Deploy the Harbor service of VMWare company through Docker to achieve a private Docker image repository.

Preparation

  • docker
  • docker-compose

Download the automatic installation program

1
2
3
4
wget https://github.com/goharbor/harbor/releases/download/v2.8.2/harbor-offline-installer-v2.8.2.tgz
tar -zxvf harbor-offline-installer-v2.8.2.tgz
rm harbor-offline-installer-v2.8.2.tgz
cd harbor

Modify the configuration file

Make a copy of the configuration file

1
cp harbor.yml.tmpl harbor.yml

Modify the configuration file

Specify the server address

  • Specify the IP address or domain name of the current server, do not use 127.0.0.1, because Harbor will be deployed in a Docker container
harbor.yml
1
hostname: 192.168.0.1

Remove HTTPS support

  • Comment out all configurations that support HTTPS as there is no certificate during the testing phase and HTTPS is not used
1
2
3
4
5
6
#https:
# https port for harbor, default is 443
# port: 443
# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path

Set the Harbor password

  • Modify the password, the default password is Harbor12345
1
harbor_admin_password: Harbor12345

Automatically deploy Harbor

1
./install.sh

First login

  • Access port 80 to enter the Harbor login page, the default username is admin, and the default password is Harbor12345

Create a new image repository

Push the image to the repository

Configure the image repository address

  • If there is no daemon.json file in the /etc/docker/ directory, create a new one

192.168.0.1:80: Address of Harbor

/etc/docker/daemon.json
1
2
3
{
"insecure-registries": ["192.168.0.1:80"]
}

Restart the Docker service

1
systemctl restart docker

Rename the image name

  • Rename the docker image name in the format of Harbor address/project name/image name:version

<id>: Image ID or container name
192.168.0.1:80: Address of Harbor

1
docker tag <id> 192.168.0.1:80/demo/demo:v1.0.0

Log in to the image repository

admin: Harbor username
Harbor12345: Harbor password
192.168.0.1:80: Address of Harbor

1
docker login -u admin -p Harbor12345 192.168.0.1:80

Push the image

1
docker push 192.168.0.1:80/demo/demo:v1.0.0

Pull the image

Log in to the image repository

  • If it is a public repository, there is no need to log in

admin: Harbor username
Harbor12345: Harbor password
192.168.0.1:80: Address of Harbor

1
docker login -u admin -p Harbor12345 192.168.0.1:80

Pull the image

1
docker pull 192.168.0.1:80:8083/demo/demo:v1.0.0

Done

  • Screenshot commemoration

References

Bilibili - Cloud Native Technology Architecture