Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of building docker private warehouse based on Harbor?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

What is the method of building docker private warehouse based on Harbor? many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

I. introduction to harbor

Mirror-based replication strategy; support LDAP/ AD domain, use through VPN connection domain; image deletion and garbage collection; image UI, convenient; audit, this function is rarely used, ELK is used to collect and analyze logs in general enterprises; RESTful API

I. harbor to build a private warehouse

1. Upload dock-compose and set permissions

[root@harbor ~] # cd / usr/local/bin/ [root@harbor bin] # rz-e [root@harbor bin] # lsdocker-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 line 5 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 the Harbor boot image and container

(1) View the image

Docker images

(2) check whether the service container is open.

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

7. Create a project in the UI interface

The browser accesses http://192.168.32.15, and the default administrator username and password is admin/Harbor12345.

Post-login interface:

Add a project

8. Test the warehouse function 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 tagging

Docker tag nginx 127.0.0.1/test_items/centos:nginx_v1docker images

(4) upload image to Harbor

Docker push 127.0.0.1/test_items/centos:nginx_v1

9. Upload the image on the client

The above operations are all done locally on the Harbor server. If another client uploads the image to Harbor, it will report the following error. The reason for this problem is that HTTPS is used by default for Docker Registry interaction, but HTTP service is used by default to build private images, so the following error occurs when interacting with private images.

(1) error phenomenon

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

(2) solution

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

(3) upload image

# download tomcat image docker pull tomcatdocker images#, tag docker tag tomcat 192.168.32.15/test_items/centos:tomcat_v1# and upload it to local warehouse docker push 192.168.32.15 Universe _ centosV1III, maintenance and management 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 options required for the Harbor.cfg configuration file: to change the Harbour configuration file, stop the existing Harbor instance and update the Harbor.cfg;, then run the prepare script to populate the configuration, and finally recreate and start the instance of Harbour.

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 prepare script to populate the configuration

Cd / usr/local/harbor/./prepare

4. Restart the service

Cd / usr/local/harbor/docker-compose up-d IV. Create Harbor users

1. 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. Whether the new users created by the test can use

# Login docker logout 192.168.29.7 login to the private repository with the newly created user and password docker login 192.168.29.77Username: zhangsanPassword: # enter the password # View the image (before download) docker images# download the image from the private repository docker pull 192.168.29.77/test_items/centos:nginx_v1# view image (after download) docker images

4. Remove the Harbor service container and all data

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

1) operate on Harbor server

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

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

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report