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

Instructions on installation and management of docker harbor

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Today, the editor will bring you an article about the installation and management of docker harbor. The editor thinks it's pretty good, so I'll share it for you as a reference. Let's follow the editor and have a look.

I. introduction of the environment

Prerequisites for the target host

Harbor is deployed as multiple Docker containers, so it can be deployed on any Linux distribution that supports Docker. The target host needs to have Python,Docker and Docker Compose installed.

Hardware

Resource capacity description cpu minimum 2cpu preferred 4cpumemory minimum 4GB preferred 8GBdisk minimum 40GB preferred 160GB

Software

The software version describes that Python2.7 and above linuxiso comes with python2.7. This step can omit Docker engine1.10 and the above installation instructions. Please refer to: https://docs.docker.com/engine/ × × × tallation/Docker compose1.6.0 and above for installation instructions. Please visit: https://docs.docker.com/compose/ × × tall/Openssl newly generated certificates and keys for Harbor.

II. Installation

Download the harbor package: https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline- × × taller-v1.7.1.tgz

Decompression

Cd / home

Tar-zxvf harbor-offline- × × taller-v1.7.1.tgz

Yum update-y

Wait patiently for a while

Install docekr and configure the accelerator and image warehouse address

Yum × × × tall docker-y

Yum × × × tall vim-y

[root@localhost docker] # cd / etc/docker/

[root@localhost docker] # ls

Certs.d daemon.json seccomp.json

Vim daemon.json

{

"registry-mirrors": ["https://o3niohlb.mirror.aliyuncs.com"],"

"× × ecure-registries": ["172.18.74.145"]

}

Please note that do not add any protocol to the IP address.

Otherwise, an error will be reported.

Systemctl daemon-reloadsystemctl enable dockersystemctl start dockersystemctl status docker

Install docker-compose

Yum × × tall epel-release-yyum × × × tall docker-compose-y

View each software version

[root@localhost] # opensslOpenSSL > versionOpenSSL 1.0.2k-fips 26 Jan 2017OpenSSL > ^ C [root@localhost ~] # python-- versionPython 2.7.5 [root@localhost ~] # [root@localhost ~] # docker- vDocker version 1.13.1, build b2f74b2/1.13.1 [root@localhost ~] # docker-compose-vdocker-compose version 1.18.0, build 8dd22a9 [root@localhost ~] #

Edit harbor profile

Cd / home/harbor/vim harbor.cfghostname = 172.18.74.145

Install Harbor

[root@localhost harbor] #. / × × tall.sh [Step 0]: checking × × tallation environment... Note: docker version: 1.13.1Note: docker-compose version: 1.18.0 [Step 1]: loading Harbor images... ae18db924eef: Loading layer 32.92 MB/32.92 MB1c06074dba9c: Loading layer 8.955 MB/8.955 MB7a719a639e34: Loading layer 3.072 kB/3.072 kB49f7bca05da9: Loading layer 2.56 kB/2.56 kBe86d69bef97e: Loading layer 2.56 kB/2.56 kB81e122d773f5: Loading layer 2.048 kB/2.048 kB5fe5adb8cf31: Loading layer 22.8 MB/22.8 MBd760045419e4: Loading layer 22.8 MB/22.8 MBLoaded image: goharbor/registry-photon:v2.6.2-v1.7.1c0f668a21621: Loading layer 133.2 MB/133.2 MBf8cb0bf39ff2: Loading layer 684 MB/684 MB444ac38a117b: Loading layer 7.68 kB/7.68 kB2e16f24ac8bc: Loading layer 212 kB/212 kBLoaded image: goharbor/harbor-migrator:v1.7.1fa2dcaba747a: Loading layer 8.955 MB/8.955 MBeeaaf4c760eb: Loading layer MB/15.6 MB98ffd6175b61: Loading layer 18.94 kB/18.94 kBfc1db6c4f652: Loading layer 15.6 MB/15.6 MBLoaded image: goharbor/harbor-adm × × erver:v1.7.18d55a6a034d6: Loading layer 8.955 MB/8.955 MB01ef68a17913: Loading layer 27.24 MB/27.24 MBf9258cfa4b48: Loading layer 5.632 kB/5.632 kBdcf5c61ede76: Loading layer 27.24 MB/27.24 MBLoaded image: goharbor/harbor-core:v1.7.11f65d10893c9: Loading layer 50.39 MB/50.39 MB358f40be2091: Loading layer 3.584 kB/3.584 kBc7f3ef058d0b: Loading layer 3.072 kB/3.072 kB154caf7c7173: Loading layer 4.096 kB/4.096 kB42c7764aa777: Loading layer 3.584 kB/3.584 kB023f3a96f324: Loading layer 10.24 kB/10.24 kBLoaded image: goharbor/harbor-log:v1.7.1a1b528067504: Loading layer 8.955 MB/8.955 MB2d3d34f3ba5b: Loading layer 21.51 MB/21.51 MBa5da70777097: Loading layer 21.51 MB/21.51 MBLoaded image: goharbor/harbor-jobservice:v1. 7.1ab31dfc84e9d: Loading layer 8.954 MB/8.954 MBb130423af762: Loading layer 13.43 MB/13.43 MB357c059d0598: Loading layer 17.3 MB/17.3 MBfabc6edfac55: Loading layer 11.26 kB/11.26 kBcfaa3b5d445a: Loading layer 3.072 kB/3.072 kB12c73a4b2c7a: Loading layer 30.72 MB/30.72 MBLoaded image: goharbor/notary-server-photon:v0.6.1-v1.7.150a6467bd619: Loading layer 113 MB/113 MB6ae61fc91943: Loading layer 11.46 MB/11.46 MB5c840c272f78: Loading layer 2.048 kB/2.048 kB077d16ebcba8: Loading layer 48.13 kB/48.13 kBb822f5ff7858: Loading layer 3.072 kB/3.072 kB4548140152fd: Loading layer 11.51 MB/11.51 MBLoaded image: goharbor/clair-photon:v2.0.7-v1.7.1232024be30e3: Loading layer 3.39 MB/3.39 MBa73624ae3fad: Loading layer 4.721 MB/4.721 MB96b8c5c532c3: Loading layer 3.584 kB/3.584 kBLoaded image: goharbor/harbor-portal:v1.7.1e2fd12afe6e8: Loading layer 63.31 MB / 63.31 MBe973513bcb58: Loading layer 40.74 MB/40.74 MB4f45af643b2b: Loading layer 6.656 kB/6.656 kB54a84094f024: Loading layer 2.048 kB/2.048 kB2d78cf8a687b: Loading layer 7.68 kB/7.68 kBe96067b83a72: Loading layer 2.56 kB/2.56 kB38a7d304147f: Loading layer 2.56 kB/2.56 kBa36c0cb6a35a: Loading layer 2.56 kB/2.56 kBLoaded image: goharbor/harbor-db:v1.7.1b0c31ad64c85: Loading layer 65.01 MB/65.01 MB22fbab41769e: Loading layer 3.072 KB/3.072 kB7f28bf5373b2: Loading layer 59.9 kB/59.9 kBabb9969cff2a: Loading layer 61.95 kB/61.95 kBLoaded image: goharbor/redis-photon:v1.7.1933cd9a15fc5: Loading layer 3.39 MB/3.39 MBLoaded image: goharbor/nginx-photon:v1.7.16ee16a137af2: Loading layer 8.955 MB/8.955 MB954443cb7d20: Loading layer 22.8 MB/22.8 MB302a998137db: Loading layer 3.072 kB/3.072 kBe342723aef9b: Loading layer 7.465 MB/7.465 MB4eeb61ed730b: Loading layer 30 . 26 MB/30.26 MBLoaded image: goharbor/harbor-registryctl:v1.7.15b40d957fafd: Loading layer 12.11 MB/12.11 MB63489681dd6c: Loading layer 17.3 MB/17.3 MB696209dcd336: Loading layer 11.26 kB/11.26 kB8dc53997aa1f: Loading layer 3.072 kB/3.072 kBcb6d560a9958: Loading layer 29.41 MB/29.41 MBLoaded image: goharbor/notary-signer-photon:v0.6.1-v1.7.1dc1e16790c89: Loading layer 8.96 MB/8.96 MB046c7e7a0100: Loading layer 35.08 MB/35.08 MB8c8428e3d6c6: Loading layer 2.048 kB/2.048 kBebb477ee35a2: Loading layer 3.072 kB/3.072 kB19636f39e29d: Loading layer 35.08 MB/35.08 MBLoaded image: goharbor/chartmuseum-photon:v0.7.1-v1.7.1 [Step 2]: preparing environment. Generated and saved secret to file: / data/secretkeyGenerated configuration file:. / common/config/nginx/nginx.confGenerated configuration file:. / common/config/adm × × × erver/envGenerated configuration file:. / common/config / core/envGenerated configuration file:. / common/config/registry/config.ymlGenerated configuration file:. / common/config/db/envGenerated configuration file:. / common/config/jobservice/envGenerated configuration file:. / common/config/jobservice/config.ymlGenerated configuration file:. / common/config/log/logrotate.confGenerated configuration file:. / common/config/registryctl/envGenerated configuration file:. / common/config/core/app.confGenerated certificate Key file:. / common/config/core/private_key.pem, cert file:. / common/config/registry/root.crtCreating harbor-log... Donee. [Step 3]: checking existing × × tance of Harbor... Creating harbor-db. DoneCreating harbor-core... Done [Step 4]: starting Harbor... Creating harbor-portal... DoneCreating nginx... DoneCreating registryctl. Creating registry. Creating harbor-adm × × erver. Creating redis. Creating harbor-db. Creating harbor-core. Creating harbor-jobservice. Creating harbor-portal. Creating nginx. ✔-Harbor has been × × talled and started successfully.----Now you should be able to visit the admin portal at http://172.18.74.145.For more details, please visit https://github.com/goharbor/harbor.

From the above, we can see that Harbor is a service based on multiple containers.

If you take a look at the images, you will find that there are a lot more. These are all the images pulled during the installation of Harbor.

[root@localhost harbor] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEgoharbor/chartmuseum-photon v0.7.1-v1. 7.1 f61c186d5b1b 4 months ago 111 MBgoharbor/harbor-migrator v1.7.1 9ec6467899b6 4 months Ago 799 MBgoharbor/redis-photon v1.7.1 c7aa92fb1c26 4 months Ago 96.3 MBgoharbor/clair-photon v2.0.7-v1.7.1 832461eef7dd 4 months Ago 165 MBgoharbor/notary-server-photon v0.6.1-v1.7.1 382cd390eaff 4 months ago 102 MBgoharbor/notary-signer-photon v0.6.1-v1. 7.1 76486e1aa1a2 4 months ago 99.6 MBgoharbor/harbor-registryctl v1.7.1 aefea98e6f92 4 months Ago 101 MBgoharbor/registry-photon v2.6.2-v1.7.1 13b348ffd0c9 4 months Ago 86.4 MBgoharbor/nginx-photon v1.7.1 9b9520572494 4 months Ago 35.5 MBgoharbor/harbor-log v1.7.1 0744800d7a4c 4 months ago 81 MBgoharbor/harbor-jobservice v1.7.1 Db96ce6ed531 4 months ago 83.8 MBgoharbor/harbor-core v1.7.1 8f253c0f9d50 4 months Ago 95.2 MBgoharbor/harbor-portal v1.7.1 b50162ab177a 4 months Ago 40.2 MBgoharbor/harbor-adm × × × erver v1.7.1 22d66cccedba 4 months ago 72 MBgoharbor/harbor-db v1.7.1 c2a95254c0bf 4 months

At this point, the installation of Harbor is complete. You can see the login page of harbor directly by visiting ip. The default login name of Harbor is admin, and the password is Harbor123456. You can log in to change the password.

III. Management

Log in to harbor

[root@localhost harbor] # docker login 172.18.74.145Username: adminPassword:Login Succeeded

Pull alpine image

[root@localhost harbor] # docker pull alpine [root@localhost harbor] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/alpine latest cdf98d1859c1 4 weeks ago 5.53 MB

Tag the image. Note that the format is image repository name / project name / image name: version number

[root@localhost harbor] # docker tag docker.io/alpine:latest 172.18.74.145/library/alpine:latest [root@localhost harbor] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE172.18.74.145/library/alpine latest cdf98d1859c1 4 weeks ago 5.53 MBdocker.io/alpine latest Cdf98d1859c1 4 weeks ago 5.53 MB

Push the image to harbor

[root@localhost harbor] # docker push 172.18.74.145/library/alpine:latest

The push refers to a repository [172.18.74.145/library/alpine]

A464c54f93a9: Pushed

Latest: digest: sha256:5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907 size: 528

View

In the default library project, there is the image we just uploaded. The number of downloads is 0. Let's pull to see the changes in the number of downloads.

[root@localhost harbor] # docker pull 172.18.74.145/library/alpineUsing default tag: latestTrying to pull repository 172.18.74.145/library/alpine... latest: Pulling from 172.18.74.145/library/alpineDigest: sha256:5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907Status: Image is up to date for 172.18.74.145/library/alpine:latest

Number of downloads + 1

Stop Harbor

This command deletes all harbor containers, but does not delete the image

[root@localhost harbor] # docker-compose down-vStopping nginx... DoneStopping harbor-portal... DoneStopping harbor-jobservice... DoneStopping harbor-core... DoneStopping redis... DoneStopping harbor-db... DoneStopping registry... DoneStopping harbor-adm × × erver. DoneStopping registryctl... DoneStopping harbor-log... DoneRemoving nginx... DoneRemoving harbor-portal... DoneRemoving harbor-jobservice... DoneRemoving harbor-core... DoneRemoving redis... DoneRemoving harbor-db... DoneRemoving registry... DoneRemoving harbor-adm × × erver. DoneRemoving registryctl... DoneRemoving harbor-log... DoneRemoving network harbor_harbor

You can see that all the containers have been stopped and deleted, while the mirror still exists.

[root@ocalhost harbor] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@localhost harbor] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE172.18.74.145/library/alpine latest cdf98d1859c1 4 weeks Ago 5.53 MBdocker.io/alpine latest cdf98d1859c1 4 weeks ago 5.53 MBgoharbor/chartmuseum-photon v0.7.1-v1.7.1 f61c186d5b1b 4 months ago 111 MBgoharbor/harbor-migrator v1.7.1 9ec6467899b6 4 months ago 799 MBgoharbor/redis-photon v1.7.1 C7aa92fb1c26 4 months ago 96.3 MBgoharbor/clair-photon v2.0.7-v1.7.1 832461eef7dd 4 months ago 165 MBgoharbor/notary-server-photon v0.6.1-v1.7.1 382cd390eaff 4 months ago 102 MBgoharbor/notary-signer-photon v0.6.1-v1.7.1 76486e1aa1a2 4 months ago 99.6 MBgoharbor/harbor-registryctl v1.7.1 aefea98e6f92 4 months ago 101 MBgoharbor/registry-photon v2.6.2-v1.7.1 13b348ffd0c9 4 months ago 86.4 MBgoharbor/nginx-photon v1.7.1 9b9520572494 4 months ago 35.5 MBgoharbor/harbor-log v1.7.1 0744800d7a4c 4 months ago 81 MBgoharbor/harbor-jobservice v1.7.1 db96ce6ed531 4 months ago 83.8 MBgoharbor/harbor-core v1.7.1 8f253c0f9d50 4 months ago 95.2 MBgoharbor/harbor-portal v1.7.1 b50162ab177a 4 months ago 40.2 MBgoharbor/harbor-adm × × erver v1.7. 1 22d66cccedba 4 months ago 72 MBgoharbor/harbor-db v1.7.1 c2a95254c0bf 4 months ago 133 MB

Custom configuration of Harbor listening port

[root@localhost harbor] # cd / home/harbor [root@localhost harbor] # vim docker-compose.yml proxy: image: goharbor/nginx-photon:v1.7.1 container_name: nginx restart: always cap_drop:-ALL cap_add:-CHOWN-SETGID-SETUID-NET_BIND_SERVICE volumes: -. / common/config/nginx:/etc/nginx:z networks:-harbor dns_search:. Ports:-8888registry 80 / / here you can change the port mapped to the local port to 8888-443 registry-core-portal-log logging: driver: "syslog" options: syslog-address: "tcp://127.0.0.1:1514" tag: "proxy".

To change the configuration of Harbor, stop the existing Harbor instance and update harbor.cfg, and reload the configuration using the prepare command

Vim harbor.cfghostname=172.18.74.145:8888./prepare

Turn on Harbor

[root@localhost harbor] # docker-compose up-dCreating harbor-portal... DoneCreating nginx... DoneCreating redis. Creating harbor-adm × × erver. Creating registry. Creating registryctl. Creating harbor-db. Creating harbor-core. Creating harbor-portal. Creating harbor-jobservice. Creating nginx.

You can see that the harbor container is started again.

[root@localhost harbor] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe913e767568e goharbor/nginx-photon:v1.7.1 "nginx- g 'daemon ... "10 seconds ago Up 7 seconds (health: starting) 0.0.0.0 health 80-> 80/tcp 0.0.0.0UR 443-> 443/tcp 0.0.0.0 seconds ago Up 4443-> 4443/tcp nginx8b1c95d68041 goharbor/harbor-jobservice:v1.7.1 "/ harbor/start.sh" 12 seconds ago Up 9 seconds harbor-jobservice39f48c79e914 goharbor/harbor-portal:v1.7.1 " Nginx-g 'daemon... "12 seconds ago Up 9 seconds (health: starting) 80/tcp harbor-portalc0735c7ecad8 goharbor/harbor-core:v1.7.1" / harbor/start.sh "13 seconds ago Up 11 seconds (health: starting) Harbor-corefd0830a7e6f9 goharbor/harbor-db:v1.7.1 "/ entrypoint.sh po..." 16 seconds ago Up 12 seconds (health: starting) 5432/tcp harbor-dbab7efc2bee1b goharbor/harbor-registryctl:v1.7.1 "/ harbor/start.sh" 16 seconds ago Up 12 seconds (health: starting) registryctl01623abd77c2 goharbor/registry-photon:v2.6.2-v1.7.1 "/ entrypoint.sh / e." 16 seconds ago Up 12 seconds (health: starting) 5000/tcp Registry9ccbf668088b goharbor/harbor-adm × × erver:v1.7.1 "/ harbor/start.sh" 16 seconds ago Up 12 seconds (health: starting) harbor-adm × × erverd35fbc13ca00 goharbor/redis-photon:v1.7.1 "docker-entrypoint..." 16 seconds ago Up 14 seconds 6379/tcp redis1933f2a457c4 goharbor/harbor-log:v1.7.1 "/ bin/sh-c / usr/l..." 17 seconds ago Up 15 seconds (health: starting) 127.0.0.1 : 1514-> 10514/tcp harbor-log

Browsers access ip:8888

By default, registry data is retained in the / data/ directory of the host, even if the Harbor container is removed and / or recreated.

[root@localhost ~] # cd / data/ [root@localhost data] # lsca_download config database job_logs psc redis registry secretkey [root@localhost data] # cd registry/ [root@localhost registry] # tree. └── docker └── registry └── v2 ├── blobs │ └── sha256 │ ├── 5c │ │ └ ── 5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907 │ │ └── data │ ├── bd │ │ └── bdf0201b3a056acc4d6062cc88cd8a4ad5979983bfb640f15a145e09ed985f92 │ │ └── data │ └── cd │ └── cdf98d1859c1beb33ec70507249d34bacf888d59c24df3204057f9a6c758dddb │ └── data └── repositories └── library └── alpine ├── _ layers │ └── sha256 │ bdf0201b3a056acc4d6062cc88cd8a4ad5979983bfb640f15a145e09ed985f92 │ │ └── link │ └── cdf98d1859c1beb33ec70507249d34bacf888d59c24df3204057f9a6c758dddb │ └── link ├── _ manifests │ ├── revisions │ │ └── sha256 │ │ └── 5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907 │ │ └── link │ └── tags │ └── latest │ ├── current │ │ └── link │ └── index │ └── sha256 │ └── 5c40b3c27b9f13c873fefb2139765c56ce97fd50230f1f2d5c91e55dec171907 │ └── link └── _ uploads29 directories 8 files

In addition, Harbor uses rsyslog to collect logs in each container, which by default are stored under / var/log/harbor/ on the host

You can troubleshoot based on these log files

[root@localhost registry] # cd / var/log/harbor/ [root@localhost harbor] # lsadm × × erver.log core.log jobservice.log portal.log postgresql.log proxy.log redis.log registryctl.log registry.log

The above is about the installation and management of docker harbor introduction, detailed use of their own use to know the specific essentials. If you want to know more about it, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report