日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

使用Harbor构建docker私有仓库

發(fā)布時(shí)間:2024/2/28 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用Harbor构建docker私有仓库 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

目錄

  • 一、概述
    • 1、什么是Harbor
    • 2、Harbor的優(yōu)勢(shì)
    • 3、Docker私有倉(cāng)庫(kù)架構(gòu)
    • 4、Harbor 配置文件以及相關(guān)參數(shù)
      • (1)所需參數(shù)
      • (2)可選參數(shù)
  • 二、使用Harbor構(gòu)建docker私有倉(cāng)庫(kù)
    • 1、部署 Harbor 服務(wù)
      • (1)下載 Harbor 安裝程序
      • (2)配置 Harbor 參數(shù)文件
      • (3)啟動(dòng) Harbor
      • (4)查看 Harbor 啟動(dòng)鏡像和容器
      • (5)在UI界面創(chuàng)建項(xiàng)目
      • (6)在本地測(cè)試倉(cāng)庫(kù)功能
      • (7)在客戶端上傳鏡像
    • 2、維護(hù)管理Harbor
      • (1)停止現(xiàn)有的 Harbor 實(shí)例
      • (2)修改配置文件 Harbor.cfg
      • (3)運(yùn)行 prepare 腳本來填充配置
      • (4)重啟服務(wù)
    • 3、創(chuàng)建 Harbor 用戶
    • 3、移除 Harbor 服務(wù)容器以及全部數(shù)據(jù)

一、概述

1、什么是Harbor

Harbor 是VMware公司開源的云本地 registry 倉(cāng)庫(kù),有可視化的Web管理界面,可以方便的管理和儲(chǔ)存 Docker 鏡像。Harbor 支持在多個(gè)倉(cāng)庫(kù)直接進(jìn)行復(fù)制鏡像,提供用戶管理和訪問控制和活動(dòng)審計(jì)。

2、Harbor的優(yōu)勢(shì)

  • 基于角色控制
  • 基于鏡像的復(fù)制策略
  • 支持LDAP/AD域,通過VPN連接域使用
  • 圖像刪除和垃圾收集
  • 圖像UI,方便
  • 審計(jì),此功能使用較少,一般企業(yè)中用ELK收集、分析日志
  • RESTful API

3、Docker私有倉(cāng)庫(kù)架構(gòu)

圖中組件解釋
Proxy:通過一個(gè)前置的反向代理統(tǒng)一接收瀏覽器、Docker客戶端的請(qǐng)求,并將請(qǐng)求轉(zhuǎn)發(fā)給后端不同的服務(wù)
Registry:負(fù)責(zé)存儲(chǔ)Docker鏡像,并處理docker push/pull命令
Core services:Harbor的核心功能,包括UI、webhook、token服務(wù)
Database:為core services提供數(shù)據(jù)庫(kù)服務(wù)
Log collector:·負(fù)責(zé)收集其他組件的log,供日后進(jìn)行分析

圖解
所有的請(qǐng)求都經(jīng)過proxy代理,proxy代理轉(zhuǎn)發(fā)給Core services和Registry,其中Core services包括UI界面、token令牌和webhook網(wǎng)頁(yè)服務(wù)功能,Registry主要提供鏡像存儲(chǔ)功能。如果要進(jìn)行下載上傳鏡像,要經(jīng)過token令牌驗(yàn)證然后從Registry獲取或上傳鏡像,每一次下載或上傳都會(huì)生成日志記錄,會(huì)記入Log collector,而用戶身份權(quán)限及一些鏡像語言信息會(huì)被存儲(chǔ)在Database中。

4、Harbor 配置文件以及相關(guān)參數(shù)

Harbor的配置文件是:/usr/local/harbor/harbor.cfg
關(guān)于 Harbor.cfg 配置文件中有兩類參數(shù):所需參數(shù)和可選參數(shù)

(1)所需參數(shù)

修改此參數(shù)后,需要運(yùn)行 install.sh腳本重新安裝 Harbour,參數(shù)才會(huì)生效。

  • hostname
    • 用于訪問用戶界面和 register 服務(wù)。
    • 它應(yīng)該是目標(biāo)機(jī)器的 IP 地址或完全限定的域名(FQDN)
    • 例如 192.168.163.100 或test.com。
    • 不要使用 localhost 或 127.0.0.1 為主機(jī)名。
  • ui_url_protocol(參數(shù)選項(xiàng):http 或 https,默認(rèn)為 http)
    • 用于訪問 UI 和令牌/通知服務(wù)的協(xié)議。
    • 如果公證處于啟用狀態(tài),則此參數(shù)必須為 https。
  • max_job_workers
    • 鏡像復(fù)制作業(yè)線程。
  • db_password
    • 用于db_auth 的MySQL數(shù)據(jù)庫(kù)root 用戶的密碼。
  • customize_crt
    • 該屬性可設(shè)置為打開或關(guān)閉,默認(rèn)打開。
    • 打開此屬性時(shí),準(zhǔn)備腳本創(chuàng)建私鑰和根證書,用于生成/驗(yàn)證注冊(cè)表令牌。
    • 當(dāng)由外部來源提供密鑰和根證書時(shí),將此屬性設(shè)置為 off。
  • ssl_cert
    • SSL 證書的路徑,僅當(dāng)協(xié)議設(shè)置為 https 時(shí)才應(yīng)用。
  • ssl_cert_key
    • SSL 密鑰的路徑,僅當(dāng)協(xié)議設(shè)置為 https 時(shí)才應(yīng)用。
  • secretkey_path
    • 用于在復(fù)制策略中加密或解密遠(yuǎn)程 register 密碼的密鑰路徑。
    • 不建議配置,有很大的安全隱患

(2)可選參數(shù)

這些參數(shù)對(duì)于更新是可選的,即用戶可以將其保留為默認(rèn)值,并在啟動(dòng) Harbor 后在 Web UI 上進(jìn)行更新。
如果進(jìn)入 Harbor.cfg,只會(huì)在第一次啟動(dòng) Harbor 時(shí)生效,隨后對(duì)這些參數(shù) 的更新,Harbor.cfg 將被忽略。
注意:如果選擇通過UI設(shè)置這些參數(shù),請(qǐng)確保在啟動(dòng)Harbour后立即執(zhí)行此操作。具體來說,必須在注冊(cè)或在 Harbor 中創(chuàng)建任何新用戶之前設(shè)置所需的

  • auth_mode
    • 當(dāng)系統(tǒng)中有用戶時(shí)(除了默認(rèn)的 admin 用戶),auth_mode 不能被修改。
  • Email
    • Harbor需要該參數(shù)才能向用戶發(fā)送“密碼重置”電子郵件,并且只有在需要該功能時(shí)才需要。
    • 請(qǐng)注意,在默認(rèn)情況下SSL連接時(shí)沒有啟用。如果SMTP服務(wù)器需要SSL,但不支持STARTTLS,那么應(yīng)該通過設(shè)置啟用SSL email_ssl = TRUE。
  • harbour_admin_password
    • 管理員的初始密碼,只在Harbour第一次啟動(dòng)時(shí)生效。
    • 之后,此設(shè)置將被忽略,并且應(yīng) UI中設(shè)置管理員的密碼。
    • 默認(rèn)的用戶名/密碼是 admin/Harbor12345。
  • auth_mode
    • 使用的認(rèn)證類型
    • 默認(rèn)情況下,它是 db_auth,即憑據(jù)存儲(chǔ)在數(shù)據(jù)庫(kù)中。
    • 對(duì)于LDAP身份驗(yàn)證,請(qǐng)將其設(shè)置為 ldap_auth。
  • self_registration
    • 啟用/禁用用戶注冊(cè)功能。
    • 禁用時(shí),新用戶只能由 Admin 用戶創(chuàng)建,只有管理員用戶可以在 Harbour中創(chuàng)建新用戶。
    • 注意:當(dāng) auth_mode 設(shè)置為 ldap_auth 時(shí),自注冊(cè)功能將始終處于禁用狀態(tài),并且該標(biāo)志被忽略。
  • Token_expiration
    • 由令牌服務(wù)創(chuàng)建的令牌的到期時(shí)間(分鐘),默認(rèn)為 30 分鐘。
    • 即登錄–退出后,30分鐘內(nèi)可以不輸入用戶名和密碼登錄,30分鐘后需要再次驗(yàn)證。
  • project_creation_restriction
    • 用于控制哪些用戶有權(quán)創(chuàng)建項(xiàng)目的標(biāo)志,表示哪些用戶可以創(chuàng)建項(xiàng)目。
    • 默認(rèn)情況下, 每個(gè)人都可以創(chuàng)建一個(gè)項(xiàng)目。
    • 如果將其值設(shè)置為“adminonly”,那么只有 admin 可以創(chuàng)建項(xiàng)目。
  • verify_remote_cert
    • 打開或關(guān)閉,默認(rèn)打開。
    • 此標(biāo)志決定了當(dāng)Harbor與遠(yuǎn)程 register 實(shí)例通信時(shí)是否驗(yàn)證 SSL/TLS 證書。
    • 將此屬性設(shè)置為 off 將繞過 SSL/TLS 驗(yàn)證,這在遠(yuǎn)程實(shí)例具有自簽名或不可信證書時(shí)經(jīng)常使用。

另外,默認(rèn)情況下,Harbour 將鏡像存儲(chǔ)在本地文件系統(tǒng)上。在生產(chǎn)環(huán)境中,可以考慮 使用其他存儲(chǔ)后端而不是本地文件系統(tǒng),如 S3、Openstack Swif、Ceph 等。但需要更新common/templates/registry/config.yml 文件。

二、使用Harbor構(gòu)建docker私有倉(cāng)庫(kù)

案例環(huán)境

主機(jī)操作系統(tǒng)主機(jī)名/IP地址主要軟件及版本
Harbor(服務(wù)端)Centos 7192.168.163.100docker
docker-compose
harbor-offline-v1.1.2
client(客戶端)Centos 7192.168.163.150docker

案例需求
通過Harbor創(chuàng)建Docker私有倉(cāng)庫(kù)
使用圖形化管理Docker私有倉(cāng)庫(kù)鏡像

實(shí)驗(yàn)準(zhǔn)備
在服務(wù)端安裝docker和docker-compose
客戶端上安裝docker
關(guān)閉防火墻
修改主機(jī)名

1、部署 Harbor 服務(wù)

Harbor 被部署為多個(gè) Docker 容器,因此可以部署在任何支持 Docker 的 Linux 發(fā)行版上。
服務(wù)端主機(jī)需要安裝Docker 和 Docker Compose。
安裝Docker:Docker的第一次接觸
安裝Docker Compose如下

放入命令壓縮包 cp -p docker-compose /usr/local/bin/ chmod +x /usr/local/bin/docker-compose

    (1)下載 Harbor 安裝程序

    Harbor:192.168.163.100
    安裝包下載

    //在線下載 wget http:// harbor.orientsoft.cn/harbor-1.2.2/harbor-offline-installer-v1.2.2.tgz//如果在先下載慢,可以使用上面的鏈接下載,在拖入 tar zxvf harbor-offline-installer-v1.2.2.tgz -C /usr/local/

    (2)配置 Harbor 參數(shù)文件

    Harbor:192.168.163.100

    vim /usr/local/harbor/harbor.cfg

    //第5行
    hostname = 192.168.163.100

      (3)啟動(dòng) Harbor

      Harbor:192.168.163.100

      sh /usr/local/harbor/install.sh
      • 1

      (4)查看 Harbor 啟動(dòng)鏡像和容器

      Harbor:192.168.163.100
      查看鏡像

      docker images #----------------------------------輸出內(nèi)容--------------------------------- REPOSITORY TAG IMAGE ID CREATED SIZE vmware/harbor-log v1.2.2 36ef78ae27df 3 years ago 200MB vmware/harbor-jobservice v1.2.2 e2af366cba44 3 years ago 164MB vmware/harbor-ui v1.2.2 39efb472c253 3 years ago 178MB vmware/harbor-adminserver v1.2.2 c75963ec543f 3 years ago 142MB vmware/harbor-db v1.2.2 ee7b9fa37c5d 3 years ago 329MB vmware/nginx-photon 1.11.13 6cc5c831fc7f 3 years ago 144MB vmware/registry 2.6.2-photon 5d9100e4350e 3 years ago 173MB vmware/postgresql 9.6.4-photon c562762cbd12 3 years ago 225MB vmware/clair v2.0.1-photon f04966b4af6c 3 years ago 297MB vmware/harbor-notary-db mariadb-10.1.10 64ed814665c6 3 years ago 324MB vmware/notary-photon signer-0.5.0 b1eda7d10640 4 years ago 156MB vmware/notary-photon server-0.5.0 6e2646682e3c 4 years ago 157MB photon 1.0 e6e4e4a2ba1b 4 years ago 128MB
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16


      查看容器

      docker ps -a #-----------------------------輸出內(nèi)容--------------------------------------- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4e2940a0d0c7 vmware/nginx-photon:1.11.13 "nginx -g 'daemon of…" 13 minutes ago Up 13 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx 2aa1257ff3c2 vmware/harbor-jobservice:v1.2.2 "/harbor/harbor_jobs…" 13 minutes ago Up 13 minutes harbor-jobservice 19c8fc2c6e83 vmware/harbor-ui:v1.2.2 "/harbor/harbor_ui" 13 minutes ago Up 13 minutes harbor-ui 8fe0eed3aa85 vmware/registry:2.6.2-photon "/entrypoint.sh serv…" 13 minutes ago Up 13 minutes 5000/tcp registry ac68e32fac3f vmware/harbor-db:v1.2.2 "docker-entrypoint.s…" 13 minutes ago Up 13 minutes 3306/tcp harbor-db d8a1d21defc4 vmware/harbor-adminserver:v1.2.2 "/harbor/harbor_admi…" 13 minutes ago Up 13 minutes harbor-adminserver 496ccc523f5d vmware/harbor-log:v1.2.2 "/bin/sh -c 'crond &…" 13 minutes ago Up 13 minutes 127.0.0.1:1514->514/tcp harbor-log
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10


      檢查服務(wù)容器是否開啟

      cd /usr/local/harbor/ docker-compose ps #--------------------------------------輸出內(nèi)容---------------------------------------Name Command State Ports ---------------------------------------------------------------------------------------------------- harbor-adminserver /harbor/harbor_adminserver Up harbor-db docker-entrypoint.sh mysqld Up 3306/tcp harbor-jobservice /harbor/harbor_jobservice Up harbor-log /bin/sh -c crond && rm -f ... Up 127.0.0.1:1514->514/tcp harbor-ui /harbor/harbor_ui Up nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp registry /entrypoint.sh serve /etc/ ... Up 5000/tcp
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14

      (5)在UI界面創(chuàng)建項(xiàng)目

      真機(jī)
      上圖檢查一切正常,此時(shí)可以打開瀏覽器訪問 http://192.168.163.100 的管理頁(yè)面,默認(rèn)的管理員用戶名和密碼是 admin/Harbor12345。

      登錄后的頁(yè)面

      添加項(xiàng)目并且填寫項(xiàng)目名稱


      (6)在本地測(cè)試倉(cāng)庫(kù)功能

      Harbor:192.168.163.100

      此時(shí)可使用 Docker 命令在本地通過 127.0.0.1 來登錄和推送鏡像。默認(rèn)情況下,
      Register 服務(wù)器在端口 80 上偵聽。

      登錄

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



      下載鏡像進(jìn)行測(cè)試

      docker pull nginx
      • 1


      鏡像打標(biāo)簽

      docker tag nginx 127.0.0.1/testproject/nginx:v1
      • 1

      上傳鏡像到Harbor

      docker push 127.0.0.1/testproject/nginx:v1
      • 1


      驗(yàn)證是否上傳成功

      (7)在客戶端上傳鏡像

      client:192.168.163.150
      上述操作都是在 Harbor 服務(wù)器本地操作。如果其他客戶端上傳鏡像到 Harbor,就會(huì)報(bào)
      如下錯(cuò)誤。出現(xiàn)這問題的原因 Docker Registry 交互默認(rèn)使用的是 HTTPS,但是搭建私有鏡
      像默認(rèn)使用的是 HTTP 服務(wù),所以與私有鏡像交互時(shí)出現(xiàn)以下錯(cuò)誤。

      docker login -u admin -p Harbor12345 http://192.168.163.100 #-------------------輸出內(nèi)容------------------------------------------ WARNING! Using --password via the CLI is insecure. Use --password-stdin. Error response from daemon: Get https://192.168.163.100/v2/: dial tcp 192.168.163.100:443: connect: connection refused
      • 1
      • 2
      • 3
      • 4

      解決方法

      vim /usr/lib/systemd/system/docker.service #--------------------修改內(nèi)容----------------------------------- ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry 192.168.163.100 --containerd=/run/containerd/containerd.sock #---------------------------------------------------------------//重啟服務(wù) systemctl daemon-reload systemctl restart docker//再次登錄 docker login -u admin -p Harbor12345 http://192.168.163.100 #----------------------輸出內(nèi)容-------------------------------------------- WARNING! Using --password via the CLI is insecure. Use --password-stdin. WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded #-------------------------------------------------------------------- docker pull tomcatdocker imagesdocker tag tomcat 192.168.163.100/testproject/tomcat:v2docker push 192.168.163.100/testproject/tomcat:v2
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7


      2、維護(hù)管理Harbor

      可以使用 docker-compose 來管理 Harbor。一些有用的命令如下所示,必須在與
      docker-compose.yml 相同的目錄中運(yùn)行。

      修改 Harbor.cfg 配置文件所需選項(xiàng)的步驟
      要更改 Harbour 的配置文件時(shí),請(qǐng)先停止現(xiàn)有的 Harbor 實(shí)例并更新 Harbor.cfg;然
      后運(yùn)行 prepare 腳本來填充配置;最后重新創(chuàng)建并啟動(dòng) Harbour 的實(shí)例。

      (1)停止現(xiàn)有的 Harbor 實(shí)例

      docker-compose down -v #---------------輸出內(nèi)容-------------------- Stopping nginx ... done Stopping harbor-jobservice ... done Stopping harbor-ui ... done Stopping registry ... done Stopping harbor-db ... done Stopping harbor-adminserver ... done Stopping harbor-log ... done Removing nginx ... done Removing harbor-jobservice ... done Removing harbor-ui ... done Removing registry ... done Removing harbor-db ... done Removing harbor-adminserver ... done Removing harbor-log ... done Removing network harbor_harbor
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17

      (2)修改配置文件 Harbor.cfg

      vim harbor.cfg
      • 1

      (3)運(yùn)行 prepare 腳本來填充配置

      ./prepare #---------------------------輸出內(nèi)容---------------------------- Clearing the configuration file: ./common/config/adminserver/env Clearing the configuration file: ./common/config/ui/env Clearing the configuration file: ./common/config/ui/app.conf Clearing the configuration file: ./common/config/ui/private_key.pem Clearing the configuration file: ./common/config/db/env Clearing the configuration file: ./common/config/jobservice/env Clearing the configuration file: ./common/config/jobservice/app.conf Clearing the configuration file: ./common/config/registry/config.yml Clearing the configuration file: ./common/config/registry/root.crt Clearing the configuration file: ./common/config/nginx/nginx.conf loaded secret from file: /data/secretkey Generated configuration file: ./common/config/nginx/nginx.conf Generated configuration file: ./common/config/adminserver/env Generated configuration file: ./common/config/ui/env Generated configuration file: ./common/config/registry/config.yml Generated configuration file: ./common/config/db/env Generated configuration file: ./common/config/jobservice/env Generated configuration file: ./common/config/jobservice/app.conf Generated configuration file: ./common/config/ui/app.conf Generated certificate, key file: ./common/config/ui/private_key.pem, cert file: ./common/config/registry/root.crt The configuration files are ready, please use docker-compose to start the service.
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16
      • 17
      • 18
      • 19
      • 20
      • 21
      • 22
      • 23

      (4)重啟服務(wù)

      docker-compose up -d #-----------輸出內(nèi)容----------------------------------- Creating network "harbor_harbor" with the default driver Creating harbor-log ... done Creating registry ... done Creating harbor-adminserver ... done Creating harbor-db ... done Creating harbor-ui ... done Creating harbor-jobservice ... done Creating nginx ... done
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10

      如果啟動(dòng)時(shí)報(bào)錯(cuò)(此報(bào)錯(cuò)比較少見,畢竟防火墻已開始就關(guān)閉了)

      docker-compose up -dCreating network "harbor_harbor" with the default driver ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-25094fc09b3c -j RETURN: iptables: No chain/target/match by that name.(exit status 1))

      解決方法:關(guān)閉防火墻后,docker需要重啟

      systemctl stop firewalld systemctl restart docker docker-compose up -d
      • 1
      • 2
      • 3

      3、創(chuàng)建 Harbor 用戶




      創(chuàng)建項(xiàng)目開發(fā)人員





      在客戶端上操作
      刪除之前打標(biāo)簽的鏡像

      docker rmi 192.168.163.100/testproject/tomcat:v2 #----------------------輸出內(nèi)容----------------------------- Untagged: 192.168.163.100/testproject/tomcat:v2 Untagged: 192.168.163.100/testproject/tomcat@sha256:8b42182fb220374cc8be73fbf4d9dba5946c9e6cb024c19f8470a27a6557e364
      • 1
      • 2
      • 3
      • 4


      測(cè)試創(chuàng)建的新用戶能否使用

      //注銷登錄 docker logout 192.168.163.100 #------------------輸出內(nèi)容-------------------------------- Removing login credentials for 192.168.163.100 #--------------------------------------------------------//使用新創(chuàng)建的用戶和密碼登錄私有倉(cāng)庫(kù) docker login 192.168.163.100 #------------------輸出內(nèi)容------------------------- Username: zhangsan Password: //輸入密碼 WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded #--------------------------------------------------//從私有倉(cāng)庫(kù)下載鏡像 docker pull 192.168.163.100/testproject/nginx:v1 #-----------------------輸出內(nèi)容----------------------------- v1: Pulling from testproject/nginx a076a628af6f: Pull complete 0732ab25fa22: Pull complete d7f36f6fe38f: Pull complete f72584a26f32: Pull complete 7125e4df9063: Pull complete Digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8 Status: Downloaded newer image for 192.168.163.100/testproject/nginx:v1 192.168.163.100/testproject/nginx:v1//查看鏡像 docker images #-------------------輸出內(nèi)容--------------------------------- REPOSITORY TAG IMAGE ID CREATED SIZE tomcat latest 040bdb29ab37 2 months ago 649MB 192.168.163.100/testproject/nginx v1 f6d0b4767a6c 2 months ago 133MB

      3、移除 Harbor 服務(wù)容器以及全部數(shù)據(jù)

      移除 Harbor 服務(wù)容器同時(shí)保留鏡像數(shù)據(jù)/數(shù)據(jù)庫(kù)
      //在Harbor服務(wù)器上操作

      docker-compose down -v Stopping nginx ... done Stopping harbor-jobservice ... done Stopping harbor-ui ... done Stopping registry ... done Stopping harbor-db ... done Stopping harbor-adminserver ... done Stopping harbor-log ... done Removing nginx ... done Removing harbor-jobservice ... done Removing harbor-ui ... done Removing registry ... done Removing harbor-db ... done Removing harbor-adminserver ... done Removing harbor-log ... done Removing network harbor_harbor
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      • 16

      如需重新部署,需要移除 Harbor 服務(wù)容器全部數(shù)據(jù)
      持久數(shù)據(jù),如鏡像,數(shù)據(jù)庫(kù)等在宿主機(jī)的/data/目錄下,日志在宿主機(jī)的
      /var/log/Harbor/目錄下。

      rm -rf /data/database/ rm -rf /data/registry/
      • 1
      • 2

      總結(jié)

      以上是生活随笔為你收集整理的使用Harbor构建docker私有仓库的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

      如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。