How to build a private Docker repository using Harbor

How to build a private Docker repository using Harbor

1. Open source warehouse management tool Harbor

Harbor is an open source Docker image repository management tool hosted by CNCF . We can use it to quickly build our own private repository. Of course, there are many options for building a private warehouse, such as registry image or Nexus officially provided by Docker . But Harbor is still a good choice.

2 Installation

There are many ways to install Harbor , such as installation through the command line, Helm installation, etc. This article demonstrates the script installation through the command line.

2.1 Install Docker and Docker-compose

First, Docker needs to be installed. Harbor is started through a bunch of containers. In addition, you need to install docker-compose , and there are certain requirements for the version. Here you can find the software package in the Rancher resource library and configure it:

Install Docker-compose :

wget http://rancher-mirror.cnrancher.com/docker-compose/v1.27.4/docker-compose-Linux-x86_64
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
chmod a+x /usr/local/bin/docker-compose

2.2 Install Harbor

2.2.1 Download and decompress

First go to GitHub Release to download the corresponding package. There are two types: offline and online . offline is larger and contains the corresponding dependencies; online does not contain the corresponding dependent components and needs to be downloaded during installation. The online package is used here because downloading things from Github may not be very fast.

download:

wget https://github.com/goharbor/harbor/releases/download/v2.1.1/harbor-online-installer-v2.1.1.tgz

Unzip:

tar zxvf harbor-online-installer-v2.1.1.tgz

2.2.2 Configuration and installation

Prepare the configuration file:

cp harbor.yml.tmpl harbor.yml

Modify the configuration: vi harbor.yml , mainly remove https and configure the server address and password. The key configurations are:

hostname: 8.134.18.166
http:
  port: 8088
# https related config
#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
harbor_admin_password: Harbor12345

After changing the configuration, start the installation:

./install.sh

A prompt will appear if the installation is successful.

3. Easy to use

3.1 Create a user with admin

Visit: http://8.134.18.166:8088/ to log in. The username is admin and the default password is Harbor12345 .

The management user admin has too high permissions. To create a normal user:

Create user information:

3.2 New User Creates a Project

Exit admin , log in with the newly created user, and then create a project to store the image:

Project created successfully:

3.3 Docker connection warehouse

3.3.1 Modify Docker configuration and restart

Configure daemon.json on a machine with docker , add "insecure-registries": ["http://8.134.18.166:8088"],

vi /etc/docker/daemon.json

The content after configuration is as follows:

{
  "insecure-registries": ["http://8.134.18.166:8088"],
  "registry-mirrors": ["https://xxx.mirror.aliyuncs.com"],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}

Restart Docker :

systemctl restart docker

3.3.2 Login and push image

Log in to the newly created warehouse:

$ docker login http://8.134.18.166:8088 --username pkslow --password Pk123456
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

tag one of the images:

docker tag nginx 8.134.18.166:8088/pkslow/nginx:latest

Upload the image to the repository:

$ docker push 8.134.18.166:8088/pkslow/nginx:latest
The push refers to repository [8.134.18.166:8088/pkslow/nginx]
cdd1d8ebeb06: Pushed 
fe08d9d9f185: Pushed 
280ddd108a0a: Pushed 
f14cffae5c1a: Pushed 
d0fe97fa8b8c: Pushed 
latest: digest: sha256:4949aa7259aa6f827450207db5ad94cabaa9248277c6d736d5e1975d200c7e43 size: 1362

Go to the web page to check, there is already a corresponding mirror:

Pulling will not be demonstrated.

This is the end of this article about how to use Harbor to build a private Docker repository. For more information about how to use Harbor to build a private Docker repository, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Harbor visualizes private image warehouse environment and service deployment example
  • Method of building docker private warehouse based on Harbor
  • Detailed explanation of building a Docker private image repository based on Harbor
  • Introduction to Harbor high availability configuration and warehouse usage

<<:  MySQL integrity constraints definition and example tutorial

>>:  In-depth study of how to use positioning in CSS (summary)

Recommend

How to implement mobile web page size adaptation

I finally finished the project at hand, and the m...

CSS implements Google Material Design text input box style (recommended)

Hello everyone, today I want to share with you ho...

Eight ways to implement communication in Vue

Table of contents 1. Component Communication 1. P...

HTML form application includes the use of check boxes and radio buttons

Including the use of check boxes and radio buttons...

Usage of mysql timestamp

Preface: Timestamp fields are often used in MySQL...

Steps to install Pyenv under Deepin

Preface In the past, I always switched Python ver...

Methods and steps to upgrade MySql5.x to MySql8.x

Several Differences Between MySQL 5.x and MySQL 8...

Five things a good user experience designer should do well (picture and text)

This article is translated from the blog Usability...

Native JavaScript to achieve skinning

The specific code for implementing skinning with ...

CSS World--Code Practice: Image Alt Information Presentation

Using the <img> element with the default sr...

Detailed steps to install the specified version of docker (1.12.6) using rpm

1. Reasons If the system is Centos7.3, the Docker...

JavaScript timer to achieve limited time flash sale function

This article shares the specific code of JavaScri...

Detailed explanation of Vue save automatic formatting line break

I searched for many ways to change it online but ...

Illustration-style website homepage design New trend in website design

You can see that their visual effects are very bea...