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

Code comment writing standards during web page production

<br />I have summarized the annotation writi...

MySQL 8.0.20 installation tutorial and detailed tutorial on installation issues

Original address: https://blog.csdn.net/m0_465798...

JavaScript file loading and blocking issues: performance optimization case study

Let me start with a question: When writing an HTM...

Zabbix monitors mysql instance method

1. Monitoring planning Before creating a monitori...

Teach you how to use docker-maven-plugin to automate deployment

1. Introduction to docker-maven-plugin In our con...

Solution to Ubuntu not being able to connect to the Internet

Problem description: I used a desktop computer an...

MySQL master-slave data is inconsistent, prompt: Slave_SQL_Running: No solution

This article uses an example to describe the solu...

JavaScript implements cool mouse tailing effects

After watching this, I guarantee that you have ha...

MySQL data aggregation and grouping

We often need to summarize data without actually ...

Basic security settings steps for centos7 server

Turn off ping scanning, although it doesn't h...

Detailed explanation of JavaScript stack and copy

Table of contents 1. Definition of stack 2. JS st...

Mysql table creation foreign key error solution

Database Table A: CREATE TABLE task_desc_tab ( id...