Method of building docker private warehouse based on Harbor

Method of building docker private warehouse based on Harbor

1. Introduction to Harbor

Image-based replication strategy; support for LDAP/AD domains, used through VPN domain connections; image deletion and garbage collection; image UI, convenient; auditing, this function is rarely used, and ELK is generally used in enterprises to collect and analyze logs; RESTful API

1. Harbor builds a private warehouse

1. Upload dock-compose and set permissions

[root@harbor ~]# cd /usr/local/bin/
[root@harbor bin]# rz -e
[root@harbor bin]# ls
docker-compose
[root@harbor bin]# chmod +x docker-compose

3. Install harbor-offline-installer-v1.2.2

[root@harbor bin]# cd /usr/local/
[root@harbor local]# rz -e
[root@harbor local]# tar zxvf harbor-offline-installer-v1.2.2.tgz

4. Configure Harbo parameter file

[root@harbor local]# vim /usr/local/harbor/harbor.cfg 
 
#Modify the fifth line hostname = 192.168.29.77

5. Start Harbor

[root@harbor local]# cd /usr/local/harbor/
[root@harbor harbor]# ls
[root@harbor harbor]# sh install.sh

6. View Harbor startup images and containers

(1) View the image

docker images

(2) Check whether the service container is enabled

cd /usr/local/harbor/
docker-compose ps

7. Create a project in the UI interface

Use a browser to access http://192.168.32.15. The default administrator username and password are admin/Harbor12345.

After login interface:

Add Item

8. Test warehouse functions locally

At this point, you can use the Docker command to log in and push the image locally through 127.0.0.1. By default, the Register server listens on port 80.

(1) Log in to the local private warehouse

docker login -u admin -p Harbor12345 http://127.0.0.1

(2) Download the image for testing

docker pull nginx

(3) Image labeling

docker tag nginx 127.0.0.1/test_items/centos:nginx_v1
docker images

(4) Upload the image to Harbor

docker push 127.0.0.1/test_items/centos:nginx_v1

9. On the client, upload the image

The above operations are all performed locally on the Harbor server. If other clients upload images to Harbor, the following error will be reported. The reason for this problem is that Docker Registry interaction uses HTTPS by default, but HTTP service is used by default when building a private image, so the following error occurs when interacting with the private image.

(1) Error phenomenon

docker login -u admin -p Harbor12345 http://192.168.29.77

(2) Solution

vim /usr/lib/systemd/system/docker.service
#Modify the content...
ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 192.168.29.33 --containerd=/run/containerd/containerd.sock
......
 
#Restart the service systemctl daemon-reload
systemctl restart docker
 
#Log in again docker login -u admin -p Harbor12345 http://192.168.29.33

(3) Upload the image

#Download the tomcat image docker pull tomcat
docker images
# docker tag tomcat 192.168.32.15/test_items/centos:tomcat_v1
#Upload to local warehouse docker push 192.168.32.15/test_items/centos:tomcat_v1

3. Maintenance and Management of Harbor

Harbor can use docker-compose to manage Harbor. Some useful commands are shown below and must be run in the same directory as docker-compose.yml.

To modify the required options in the Harbor.cfg configuration file: To change Harbor's configuration file, first stop the existing Harbor instance and update Harbor.cfg; then run the prepare script to populate the configuration; finally recreate and start the Harbor instance.

1. Stop the existing Harbor instance

cd /usr/local/harbor/
docker-compose down -v

2. Modify the configuration file Harbor.cfg

cd /usr/local/harbor/
vim harbor.cfg

3. Run the prepare script to populate the configuration

cd /usr/local/harbor/
./prepare

4. Restart the service

cd /usr/local/harbor/
docker-compose up -d

4. Create Harbor User

1. Create a new user

2. Operate on the client to delete the previously tagged image

docker rmi 192.168.29.77/test_items/centos:tomcat_v1

3. Test whether the newly created user can use it

#Logout docker logout 192.168.29.77
#Use the newly created user and password to log in to the private warehouse docker login 192.168.29.77
Username: zhangsan
Password: #Enter password#View the image (before downloading)
docker images
#Download the image from the private warehouse docker pull 192.168.29.77/test_items/centos:nginx_v1
#View the image (after downloading)
docker images

4. Remove the Harbor service container and all data

Remove the Harbor service container while retaining the image data/database

1) Operation on Harbor server

cd /usr/local/harbor/
docker-compose down -v

(2) If you need to redeploy, you need to remove all data in the Harbor service container, including persistent data, such as images. The database is in the /data/ directory of the host machine, and the log is in the /var/log/Harbor/ directory of the host machine.

This is the end of this article about building a docker private repository with Harbor. For more relevant content about Harbor docker private 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
  • How to build a private Docker repository using Harbor
  • Detailed explanation of building a Docker private image repository based on Harbor
  • Introduction to Harbor high availability configuration and warehouse usage

<<:  Details on using order by in MySQL

>>:  Implementation of CSS text shadow gradually blurring effect

Recommend

Detailed example of HTML element blocking Flash

Copy code The code is as follows: wmode parameter...

MySQL 5.7.19 winx64 free installation version configuration tutorial

mysql-5.7.19-winx64 installation-free version con...

JavaScript to achieve uniform animation effect

This article example shares the specific code for...

Quickly learn MySQL basics

Table of contents Understanding SQL Understanding...

Sample code for implementing dark mode with CSS variables

Recently, WeChat was forced by Apple to develop a...

jQuery implements clicking left and right buttons to switch pictures

This article example shares the specific code of ...

19 MySQL optimization methods in database management

After MySQL database optimization, not only can t...

Node.js+express message board function implementation example

Table of contents Message Board Required librarie...

4 functions implemented by the transform attribute in CSS3

In CSS3, the transform function can be used to im...

The simplest form implementation of Flexbox layout

Flexible layout (Flexbox) is becoming increasingl...

A brief talk about cloning JavaScript

Table of contents 1. Shallow cloning 2. Deep clon...

CSS to achieve chat bubble effect

1. Rendering JD Effect Simulation Effect 2. Princ...