{"id":1191,"date":"2024-07-09T16:06:49","date_gmt":"2024-07-09T08:06:49","guid":{"rendered":"http:\/\/118.178.124.79\/wordpress\/?p=1191"},"modified":"2025-05-23T12:42:46","modified_gmt":"2025-05-23T04:42:46","slug":"harbo%e8%af%be%e4%bb%b6%e9%83%a8%e7%bd%b2","status":"publish","type":"post","link":"https:\/\/minglelu.cn\/index.php\/2024\/07\/09\/1191\/","title":{"rendered":"harbo\u8bfe\u4ef6\u90e8\u7f72"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\" id=\"\u5b89\u88c5\u90e8\u7f72\">\u5b89\u88c5\u90e8\u7f72<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u5b89\u88c5\u90e8\u7f72-docker\">\u5b89\u88c5\u90e8\u7f72 docker<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@harbor ~]# vim \/etc\/hosts192.168.1.30 &nbsp;  harbor\n# \u5b89\u88c5\u90e8\u7f72 docker \u53ca compose \u7ec4\u4ef6[root@harbor ~]# dnf install -y docker-ce docker-compose-plugin[root@harbor ~]# systemctl enable --now docker<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u62f7\u8d1d public\/harbor-v2.7.0.tgz \u5230 harbor \u4e3b\u673a<br><code>rsync -av public\/harbor-v2.7.0.tgz 192.168.1.30:.\/<\/code><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u521b\u5efa-https-\u8bc1\u4e66\">\u521b\u5efa https \u8bc1\u4e66<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u5bfc\u5165 harbor \u9879\u76ee\u955c\u50cf[root@harbor ~]# tar -zxf harbor-v2.7.0.tgz -C \/usr\/local\/[root@harbor ~]# cd \/usr\/local\/harbor[root@harbor harbor]# docker load -i harbor.v2.7.0.tar.gz# \u521b\u5efa https \u8bc1\u4e66[root@harbor harbor]# mkdir tls[root@harbor harbor]# openssl genrsa -out tls\/cert.key 2048[root@harbor harbor]# openssl req -new -x509 -days 3650 \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -key tls\/cert.key -out tls\/cert.crt \\ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -subj \"\/C=CN\/ST=BJ\/L=BJ\/O=Tedu\/OU=NSD\/CN=harbor\"<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u521b\u5efa\u5e76\u542f\u52a8\u9879\u76ee\">\u521b\u5efa\u5e76\u542f\u52a8\u9879\u76ee<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u4fee\u6539\u914d\u7f6e\u6587\u4ef6[root@harbor harbor]# cp harbor.yml.tmpl harbor.yml[root@harbor harbor]# vim harbor.yml05: &nbsp;  hostname: harbor08: &nbsp; &nbsp;# http:10: &nbsp; &nbsp; &nbsp;# port: 8017: &nbsp;  certificate: \/usr\/local\/harbor\/tls\/cert.crt18: &nbsp;  private_key: \/usr\/local\/harbor\/tls\/cert.key34: &nbsp;  harbor_admin_password: admin123\n# \u9884\u5b89\u88c5\u73af\u5883\u68c0\u67e5\uff0c\u751f\u6210\u9879\u76ee\u6587\u4ef6[root@harbor harbor]# \/usr\/local\/harbor\/prepare# \u521b\u5efa\u5e76\u542f\u52a8\u9879\u76ee[root@harbor harbor]# docker compose -f docker-compose.yml up -d# \u6dfb\u52a0\u5f00\u673a\u81ea\u542f\u52a8[root@harbor harbor]# chmod 0755 \/etc\/rc.d\/rc.local[root@harbor harbor]# echo \"\/usr\/bin\/docker compose -p harbor start\" &gt;&gt;\/etc\/rc.d\/rc.local<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u67e5\u770b\u9a8c\u8bc1\u9879\u76ee<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u67e5\u770b\u9879\u76ee[root@harbor harbor]# docker compose lsNAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  STATUS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  CONFIG FILESharbor &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  running(9) &nbsp; &nbsp; &nbsp; &nbsp;  \/usr\/local\/harbor\/docker-compose.yml# \u67e5\u770b\u5bb9\u5668\u72b6\u6001[root@harbor harbor]# docker compose -p harbor psNAME &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  COMMAND &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  SERVICE &nbsp; &nbsp; &nbsp; STATUSharbor-core &nbsp; &nbsp; &nbsp; &nbsp; \"\/harbor\/entrypoint.\u2026\" &nbsp; core &nbsp; &nbsp; &nbsp; &nbsp;  running (healthy)harbor-db &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"\/docker-entrypoint.\u2026\" &nbsp; postgresql &nbsp;  running (healthy)harbor-jobservice &nbsp; \"\/harbor\/entrypoint.\u2026\" &nbsp; jobservice &nbsp;  running (healthy)harbor-log &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\/bin\/sh -c \/usr\/loc\u2026\" &nbsp; log &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; running (healthy)harbor-portal &nbsp; &nbsp; &nbsp; \"nginx -g 'daemon of\u2026\" &nbsp; portal &nbsp; &nbsp; &nbsp;  running (healthy)nginx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"nginx -g 'daemon of\u2026\" &nbsp; proxy &nbsp; &nbsp; &nbsp; &nbsp; running (healthy)redis &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \"redis-server \/etc\/r\u2026\" &nbsp; redis &nbsp; &nbsp; &nbsp; &nbsp; running (healthy)registry &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\"\/home\/harbor\/entryp\u2026\" &nbsp; registry &nbsp; &nbsp;  running (healthy)registryctl &nbsp; &nbsp; &nbsp; &nbsp; \"\/home\/harbor\/start.\u2026\" &nbsp; registryctl &nbsp; running (healthy)<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u901a\u8fc7 ELB \u53d1\u5e03 harbor \u670d\u52a1\uff0c\u901a\u8fc7\u6d4f\u89c8\u5668\u914d\u7f6e\u7ba1\u7406<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"harbor-\u7ba1\u7406\">harbor \u7ba1\u7406<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-responsive\"><table class=\"table\" ><thead><tr><th>\u5bb9\u5668\u7ba1\u7406\u547d\u4ee4<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>docker login<\/td><td>\u767b\u5f55\u79c1\u6709\u955c\u50cf\u4ed3\u5e93<\/td><\/tr><tr><td>docker logout<\/td><td>\u9000\u51fa\u767b\u5f55<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u767b\u5f55\u79c1\u6709\u4ed3\u5e93\">\u767b\u5f55\u79c1\u6709\u4ed3\u5e93<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u6dfb\u52a0\u4e3b\u673a\u914d\u7f6e[root@docker ~]# vim \/etc\/hosts192.168.1.30    harbor192.168.1.35    registry# \u6dfb\u52a0\u79c1\u6709\u4ed3\u5e93\u914d\u7f6e[root@docker ~]# vim \/etc\/docker\/daemon.json{ &nbsp; &nbsp;\"registry-mirrors\": [\"https:\/\/harbor:443\", \"http:\/\/registry:5000\"], &nbsp; &nbsp;\"insecure-registries\":[\"harbor:443\", \"registry:5000\"]}[root@docker ~]# systemctl restart docker\n# \u767b\u5f55 harbor \u4ed3\u5e93[root@docker ~]# docker login harbor:443Username: luckPassword: ********... ...Login Succeeded# \u8ba4\u8bc1\u4fe1\u606f\u8bb0\u5f55\u6587\u4ef6[root@docker ~]# cat \/root\/.docker\/config.json {    \"auths\": {        \"harbor:443\": {            \"auth\": \"bHVjazoqKioqKioqKg==\"        }    }}# \u9000\u51fa\u767b\u5f55[root@docker ~]# docker logout harbor:443Removing login credentials for harbor:443<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u4e0a\u4f20\u955c\u50cf\">\u4e0a\u4f20\u955c\u50cf<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u8bbe\u7f6e\u6807\u7b7e[root@docker ~]# docker tag rockylinux:8.5 harbor:443\/myimg\/rockylinux:8.5# \u6ca1\u6709\u767b\u5f55\u4e0a\u4f20\u5931\u8d25[root@docker ~]# docker push harbor:443\/myimg\/rockylinux:8.565dbea0a4b39: Preparing unauthorized: unauthorized to access repository ......\n# \u767b\u5f55\u6210\u529f\u540e\u624d\u53ef\u4ee5\u4e0a\u4f20[root@docker ~]# docker login harbor:443Username: luckPassword: ********\nLogin Succeeded# \u4e0a\u4f20\u6210\u529f[root@docker ~]# docker push harbor:443\/myimg\/rockylinux:8.5 The push refers to repository [harbor:443\/myimg\/rockylinux]......\n# \u8bbe\u7f6e\u6807\u7b7e[root@docker ~]# docker tag myos:latest harbor:443\/library\/myos:latest# \u4e0a\u4f20\u955c\u50cf\u5230 library \u9879\u76ee\uff0c\u6ca1\u6709\u6743\u9650\u4e0a\u4f20\u5931\u8d25[root@docker ~]# docker push harbor:443\/library\/myos:latestThe push refers to repository [harbor:443\/library\/myos]65dbea0a4b39: Preparing unauthorized: unauthorized to access repository: ......\n# \u8d4b\u6743\u540e\u91cd\u65b0\u4e0a\u4f20\u955c\u50cf[root@docker ~]# docker push harbor:443\/library\/myos:latestThe push refers to repository [harbor:443\/library\/myos]......<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6848\u4f8b\u516d\uff1a\u4e0a\u4f20\u955c\u50cf\u5230 library \u9879\u76ee<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@docker ~]# docker tag myos:httpd harbor:443\/myimg\/httpd:latest[root@docker ~]# docker push harbor:443\/myimg\/httpd:latest[root@docker ~]# docker rmi harbor:443\/myimg\/httpd:latest[root@docker ~]# for i in 8.5 httpd nginx php-fpm latest;do &nbsp;  docker tag myos:${i} harbor:443\/library\/myos:${i} &nbsp;  docker push harbor:443\/library\/myos:${i} &nbsp;  docker rmi myos:${i} harbor:443\/library\/myos:${i}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u90e8\u7f72 \u5b89\u88c5\u90e8\u7f72 docker [root@harbor ~]# vim \/etc\/hosts192.168.1.30 &nbsp; harbor # \u5b89\u88c5\u90e8\u7f72 docker \u53ca compose \u7ec4\u4ef6[root@harbor ~]# dnf install -y docker-ce docker-compose-plugin[root@harbor ~]# systemctl enable &#8212; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,1],"tags":[],"class_list":["post-1191","post","type-post","status-publish","format-standard","hentry","category-cloud-computing","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/posts\/1191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1191"}],"version-history":[{"count":1,"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/posts\/1191\/revisions"}],"predecessor-version":[{"id":1192,"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/posts\/1191\/revisions\/1192"}],"wp:attachment":[{"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/minglelu.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}