国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Docker分布式倉庫

這篇具有很好參考價值的文章主要介紹了Docker分布式倉庫。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

Harbor 是一個用于存儲和分發(fā) Docker 鏡像的企業(yè)級 Registry 服務器,由 vmware
開源,其通過添加一些企業(yè)必需的功能特性,例如安全、標識和管理等,擴展了開源
Docker Distribution。作為一個企業(yè)級私有 Registry 服務器,Harbor 提供了更
好的性能和安全。提升用戶使用 Registry 構建和運行環(huán)境傳輸鏡像的效率。Harbor
支持安裝在多個 Registry 節(jié)點的鏡像資源復制,鏡像全部保存在私有 Registry 中,
確保數(shù)據(jù)和知識產(chǎn)權在公司內(nèi)部網(wǎng)絡中管控,另外,Harbor 也提供了高級的安全
特性,諸如用戶管理,訪問控制和活動審計等。

一. Harbor 功能介紹

基于角色的訪問控制:用戶與 Docker 鏡像倉庫通過“項目”進行組織管理,一個用戶可
以對多個鏡像倉庫在同一命名空間(project)里有不同的權限。
鏡像復制:鏡像可以在多個 Registry 實例中復制(同步)。尤其適合于負載均衡,高
可用,混合云和多云的場景。
圖形化用戶界面:用戶可以通過瀏覽器來瀏覽,檢索當前 Docker 鏡像倉庫,管理項目
和命名空間。
AD/LDAP 支:Harbor 可以集成企業(yè)內(nèi)部已有的 AD/LDAP,用于鑒權認證管理。
審計管理:所有針對鏡像倉庫的操作都可以被記錄追溯,用于審計管理。
國際化:已擁有英文、中文、德文、日文和俄文的本地化版本。更多的語言將會添加進來。
RESTful API - RESTful API:提供給管理員對于 Harbor 更多的操控, 使得與其它管
理軟件集成變得更容易。
部署簡單:提供在線和離線兩種安裝工具, 也可以安裝到 vSphere 平臺(OVA 方
式)虛擬設備。

[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-fYthEXdg-1692318555908)(png/2020-02-20-21-45-44.png)]

nginx:            harbor的一個反向代理組件,代理registry、ui、token等服務。這個代理會轉發(fā)
                   harbor web和docker client的各種請求到后端服務上。

harbor-adminserver:harbor系統(tǒng)管理接口,可以修改系統(tǒng)配置以及獲取系統(tǒng)信息。
harbor-db:         存儲項目的元數(shù)據(jù)、用戶、規(guī)則、復制策略等信息。
harbor-jobservice: harbor里面主要是為了鏡像倉庫之前同步使用的。
harbor-log:        收集其他harbor的日志信息。
harbor-ui:         一個用戶界面模塊,用來管理registry。
registry:          存儲docker images的服務,并且提供pull/push服務。
redis:             存儲緩存信息
webhook:           當registry中的image狀態(tài)發(fā)生變化的時候去記錄更新日志、復制等操作。
token service:     在docker client進行pull/push的時候負責token的發(fā)放。

二. Harbor 安裝

Server1 安裝 Docker

[root@docker-server-node1 ~]# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@docker-server-node1 ~]# yum install docker-ce -y
[root@docker-server-node1 ~]# systemctl start docker

Server2 安裝 Docker

[root@docker-server-node2 ~]# wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@docker-server-node2 ~]# yum install docker-ce -y
[root@docker-server-node2 ~]# systemctl start docker

下載 Harbor 安裝包

本次使用當前 harbor 1.7.6 離線安裝包,具體名稱為
harbor-offline-installer-v1.7.6.tgz

離線安裝包

推薦使用離線完整安裝包

[root@docker-server-node1 ~]# cd /usr/local/src/
[root@docker-server-node1 src]# wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.5.tgz

在線安裝包

不推薦使用在線安裝包安裝,需要從網(wǎng)絡下載全部所需文件

[root@docker-server-node1 src]# wget
https://github.com/vmware/harbor/releases/download/v1.7.5/harbor-online-
installer-v1.10.1.tgz

三.配置 Harbor

3.1 解壓并編輯 harbor.cfg

[root@docker-server-node1 src]# tar -xf harbor-offline-installer-v1.7.6.tgz
[root@docker-server-node1 src]# ln -sv /usr/local/src/harbor /usr/local/
‘/usr/local/harbor’ -> ‘/usr/local/src/harbor’

[root@docker-server-node1 src]# cd /usr/local/harbor/
[root@docker-server-node1 harbor]# ll
total 587744
drwxr-xr-x 3 root root        23 Feb 20 22:54 common
-rw-r--r-- 1 root root      3398 Feb 10 14:18 common.sh
-rw-r--r-- 1 root root       939 Sep 12 11:27 docker-compose.chartmuseum.yml
-rw-r--r-- 1 root root       975 Sep 12 11:27 docker-compose.clair.yml
-rw-r--r-- 1 root root      1434 Sep 12 11:27 docker-compose.notary.yml
-rw-r--r-- 1 root root      5608 Sep 12 11:27 docker-compose.yml
drwxr-xr-x 2 root root        35 Feb 20 22:44 goharbor
-rw-r--r-- 1 root root      8033 Sep 12 11:27 harbor.cfg
-rw-r--r-- 1 root root 600483180 Sep 12 11:28 harbor.v1.7.6.tar.gz
-rw-r--r-- 1 root root      5880 Feb 20 22:39 harbor.yml
drwxr-xr-x 2 root root        24 Feb 20 22:44 input
-rwxr-xr-x 1 root root      5739 Sep 12 11:27 install.sh
-rw-r--r-- 1 root root     11347 Sep 12 11:27 LICENSE
-rw-r--r-- 1 root root   1263409 Sep 12 11:27 open_source_license
-rwxr-xr-x 1 root root     36337 Sep 12 11:27 prepare

3.2 更新 harbor 配置

3.2.1 首次部署更新操作

# 使用prepare腳本更新配置
[root@docker-server-node1 harbor]# ./prepare
Generated and saved secret to file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/core/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/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/core/app.conf
Generated certificate, key file: ./common/config/core/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.

執(zhí)行完畢后會在當前目錄生成一個 docker-compose.yml 文件,用于配置數(shù)據(jù)目
錄等配置信息。

[root@docker-server-node1 harbor]# ll docker-compose.yml
-rw-r--r-- 1 root root 5608 Sep 12 11:27 docker-compose.yml

3.2.2 后期修改配置操作

如果 harbor 運行一段時間之后需要更改配置,則步驟如下:

停止 harbor 編輯配置文件
[root@docker-server-node1 harbor]# docker-compose stop
[root@docker-server-node1 harbor]# vim harbor.cfg
...
更新配置
[root@docker-server-node1 harbor]# ./prepare  # 使用該腳本更新配置,先刪除,后再生成
Clearing the configuration file: ./common/config/adminserver/env
Clearing the configuration file: ./common/config/core/env
Clearing the configuration file: ./common/config/core/app.conf
Clearing the configuration file: ./common/config/core/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/config.yml
Clearing the configuration file: ./common/config/registry/config.yml
Clearing the configuration file: ./common/config/registry/root.crt
Clearing the configuration file: ./common/config/registryctl/env
Clearing the configuration file: ./common/config/registryctl/config.yml
Clearing the configuration file: ./common/config/nginx/nginx.conf
Clearing the configuration file: ./common/config/log/logrotate.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/core/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/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/core/app.conf
Generated certificate, key file: ./common/config/core/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.
啟動 harbor
[root@docker-server-node1 harbor]# docker-compose start
Starting log         ... done
Starting registry    ... done
Starting registryctl ... done
Starting postgresql  ... done
Starting adminserver ... done
Starting core        ... done
Starting portal      ... done
Starting redis       ... done
Starting jobservice  ... done
Starting proxy       ... done

3.3 官方推薦的方式啟動 harbor

3.3.1 部署

[root@docker-server-node1 harbor]# yum install python-pip –y
[root@docker-server-node1 harbor]# pip install docker-compose
......
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o
    _posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory  # 該錯誤是因為缺失python-devel
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pn2G8c/subprocess32/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-U1nvER-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-pn2G8c/subprocess32/
You are using pip version 8.1.2, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

# 安裝python-devel
[root@docker-server-node1 harbor]# yum install python-devel

[root@docker-server-node1 harbor]# pip install docker-compose
Collecting docker-compose
......
Running setup.py install for functools32 ... done
  Running setup.py install for PyYAML ... done
  Running setup.py install for pycparser ... done
Successfully installed PyYAML-5.3 attrs-19.3.0 backports.shutil-get-terminal-size-1.0.0 bcrypt-3.1.7 cached-property-1.5.1 cffi-1.14.0 configparser-4.0.2 contextlib2-0.6.0.post1 cryptography-2.8 docker-4.2.0 docker-compose-1.25.4 enum34-1.1.6 functools32-3.2.3.post2 importlib-metadata-1.5.0 jsonschema-3.2.0 paramiko-2.7.1 pathlib2-2.3.5 pycparser-2.19 pynacl-1.3.0 pyrsistent-0.15.7 scandir-1.10.0 subprocess32-3.5.4 unknown-0.0.0 websocket-client-0.57.0


[root@docker-server-node1 harbor]# ./install.sh  #官方構建harbor和啟動方式,推薦此方法,會下載官方的docker 鏡像
[root@docker-server-node2 harbor]# ./install.sh

[Step 0]: checking installation environment ...

Note: docker version: 19.03.6

Note: docker-compose version: 1.25.4

[Step 1]: loading Harbor images ...
b80136ee24a4: Loading layer [==================================================>]  34.25MB/34.25MB
1f2db9bc717e: Loading layer [==================================================>]  63.49MB/63.49MB
3ea31adb1f16: Loading layer [==================================================>]  52.48MB/52.48MB
70134bbcd2db: Loading layer [==================================================>]  6.656kB/6.656kB
1f1b4fc154ff: Loading layer [==================================================>]  2.048kB/2.048kB
f16fb7c6177e: Loading layer [==================================================>]   7.68kB/7.68kB
c63d53b4b8d0: Loading layer [==================================================>]   2.56kB/2.56kB
787514dd6c1a: Loading layer [==================================================>]   2.56kB/2.56kB
381c81ec71b2: Loading layer [==================================================>]   2.56kB/2.56kB
......
[Step 2]: preparing environment ...
Generated and saved secret to file: /data/secretkey
Generated configuration file: ./common/config/nginx/nginx.conf
Generated configuration file: ./common/config/adminserver/env
Generated configuration file: ./common/config/core/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/config.yml
Generated configuration file: ./common/config/log/logrotate.conf
Generated configuration file: ./common/config/registryctl/env
Generated configuration file: ./common/config/core/app.conf
Generated certificate, key file: ./common/config/core/private_key.pem, cert file: ./common/config/registry/root.crt
The configuration files are ready, please use docker-compose to start the service.


[Step 3]: checking existing instance of Harbor ...


[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry           ... done
Creating harbor-db          ... done
Creating registryctl        ... done
Creating redis              ... done
Creating harbor-adminserver ... done
Creating harbor-core        ... done
Creating harbor-portal      ... done
Creating harbor-jobservice  ... done
Creating nginx              ... done

? ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://192.168.100.19.
For more details, please visit https://github.com/goharbor/harbor .

3.3.2 查看本地鏡像

[root@docker-server-node2 harbor]# docker images
REPOSITORY                                                 TAG                 IMAGE ID            CREATED             SIZE
goharbor/chartmuseum-photon                                v0.8.1-v1.7.6       ca4e65cc8cbf        5 months ago        114MB
goharbor/harbor-migrator                                   v1.7.6              bd65976b2563        5 months ago        680MB
goharbor/redis-photon                                      v1.7.6              477066fd0e02        5 months ago        109MB
goharbor/clair-photon                                      v2.0.8-v1.7.6       a65550304aa5        5 months ago        165MB
goharbor/notary-server-photon                              v0.6.1-v1.7.6       1bfca6aac750        5 months ago        136MB
goharbor/notary-signer-photon                              v0.6.1-v1.7.6       8535add7bfa5        5 months ago        133MB
goharbor/harbor-registryctl                                v1.7.6              bb06dcda87fa        5 months ago        103MB
goharbor/registry-photon                                   v2.6.2-v1.7.6       8fa930eedbea        5 months ago        87.7MB
goharbor/nginx-photon                                      v1.7.6              fea7c162d250        5 months ago        37MB
goharbor/harbor-log                                        v1.7.6              f9b50bc6e136        5 months ago        82.6MB
goharbor/harbor-jobservice                                 v1.7.6              cfac2ab2d45a        5 months ago        85.1MB
goharbor/harbor-core                                       v1.7.6              37379145c410        5 months ago        96.6MB
goharbor/harbor-portal                                     v1.7.6              eafab006217d        5 months ago        41.7MB
goharbor/harbor-adminserver                                v1.7.6              2d91210e25ed        5 months ago        73.3MB

3.3.3 查看本地端口

[root@docker-server-node2 harbor]# ss -ntl
State      Recv-Q Send-Q                 Local Address:Port            Peer Address:Port
LISTEN     0      100                        127.0.0.1:25                         *:*
LISTEN     0      128                        127.0.0.1:9000                       *:*
LISTEN     0      1024                       127.0.0.1:1514                       *:*
LISTEN     0      50                                 *:3306                       *:*
LISTEN     0      128                                *:111                        *:*
LISTEN     0      128                                *:22                         *:*
LISTEN     0      100                            [::1]:25                      [::]:*
LISTEN     0      1024                            [::]:443                     [::]:*
LISTEN     0      1024                            [::]:4443                    [::]:*
LISTEN     0      128                             [::]:111                     [::]:*
LISTEN     0      1024                            [::]:80                      [::]:*
LISTEN     0      128                             [::]:22                      [::]:*

3.3.4 訪問 web 管理界面

Server2:192.168.100.19

Server1:192.168.100.10

3.4 非官方推薦的方式啟動 harbor

[root@docker-server-node1 harbor]# docker-compose up -d

四. 配置 docker 使用 harbor 倉庫

4.1 編輯 docker 啟動文件并重啟

[root@docker-server-node2 ~]# vim /usr/lib/systemd/system/docker.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.100.19:5000 --insecure-registry 192.168.100.10:5000
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

[root@docker-server-node2 harbor]# systemctl daemon-reload
[root@docker-server-node2 harbor]# systemctl restart docker
[root@docker-server-node2 harbor]# docker-compose start

4.2 驗證能否登陸

[root@docker-server-node1 harbor]# docker login 192.168.100.19
Username: admin
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-store

Login Succeeded

4.3 測試上傳鏡像

將之前單機倉庫構構建的 Nginx 鏡像上傳到 harbor 服務器用于測試

# 貼tag
[root@docker-server-node1 harbor]# docker tag alpine:latest 192.168.100.10/library/alpine:latest

# 登錄
[root@docker-server-node1 harbor]# docker login 192.168.100.19
Username: admin
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-store

Login Succeeded

# 上傳
[root@docker-server-node2 harbor]# docker push 192.168.100.19/library/alpine:latest
The push refers to repository [192.168.100.19/library/alpine]
5216338b40a7: Pushed
latest: digest: sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45 size: 528

web 界面確認

4.4 測試從 harbor 下載鏡像使用

需要從 192.168.100.19 下載的 dockerd 都需要改啟動文件加上
–insecure-registry 選項

[root@docker-server-node2 ~]# vim /usr/lib/systemd/system/docker.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.100.19:5000 --insecure-registry 192.168.100.10:5000
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

[root@docker-server-node2 harbor]# systemctl daemon-reload
[root@docker-server-node2 harbor]# systemctl restart docker
[root@docker-server-node2 harbor]# docker-compose start

測試下載,點擊復制 pull 命令

[root@docker-server-node2 harbor]# docker pull 192.168.100.19/library/alpine:latest

[root@docker-server-node2 harbor]# docker pull 192.168.100.19/library/alpine:latest
latest: Pulling from library/alpine
Digest: sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45
Status: Downloaded newer image for 192.168.100.19/library/alpine:latest
192.168.100.19/library/alpine:latest

[root@docker-server-node2 src]# docker images
[root@docker-server-node2 harbor]# docker images | grep alpine
192.168.100.19/library/alpine                              latest              e7d92cdc71fe        5 weeks ago         5.59MB
...

[root@docker-server-node2 harbor]# docker run --rm -it 192.168.100.19/library/alpine:latest sh
/ # cat /etc/issue
Welcome to Alpine Linux 3.11
Kernel \r on an \m (\l)

/ #

五.實現(xiàn) harbor 高可用

Harbor 有兩種高可用實現(xiàn)方式:
基于共享存儲實現(xiàn)
基于鏡像復制實現(xiàn)

Harbor 支持基于策略的 Docker 鏡像復制功能,這類似于 MySQL 的主從同步,
其可以實現(xiàn)不同的數(shù)據(jù)中心、不同的運行環(huán)境之間同步鏡像,并提供友好的管理
界面,大大簡化了實際運維中的鏡像管理工作,已經(jīng)有用很多互聯(lián)網(wǎng)公司使用
harbor 搭建內(nèi)網(wǎng) docker 倉庫的案例,并且還有實現(xiàn)了雙向復制的案列。

5.1 新部署一臺 harbor 服務器

Server1:192.168.100.10

此處 Server1 為從 Harbor,主 Harbor 為 Server2:192.168.100.19
主在向從復制鏡像時,需要從 Harbor 有相同的鏡像倉庫名。此實驗都使
用默認的 library。

部署:

[root@docker-server-node1 src]# pwd
/usr/local/src
[root@docker-server-node1 src]# tar xf harbor-offline-installer-v1.7.6.tgz
[root@docker-server-node1 local]# ln -s /usr/local/src/harbor /usr/local/harbor
[root@docker-server-node1 harbor]# pwd
/usr/local/harbor
[root@docker-server-node1 harbor]# ll
total 587744
drwxr-xr-x 4 root root        37 Feb 20 23:00 common
-rw-r--r-- 1 root root      3398 Feb 10 14:18 common.sh
-rw-r--r-- 1 root root       939 Sep 12 11:27 docker-compose.chartmuseum.yml
-rw-r--r-- 1 root root       975 Sep 12 11:27 docker-compose.clair.yml
-rw-r--r-- 1 root root      1434 Sep 12 11:27 docker-compose.notary.yml
-rw-r--r-- 1 root root      5608 Sep 12 11:27 docker-compose.yml
drwxr-xr-x 2 root root        35 Feb 20 22:44 goharbor
-rw-r--r-- 1 root root      8016 Feb 20 23:11 harbor.cfg
-rw-r--r-- 1 root root 600483180 Sep 12 11:28 harbor.v1.7.6.tar.gz
-rw-r--r-- 1 root root      5880 Feb 20 22:39 harbor.yml
drwxr-xr-x 2 root root        24 Feb 20 22:44 input
-rwxr-xr-x 1 root root      5739 Sep 12 11:27 install.sh
-rw-r--r-- 1 root root     11347 Sep 12 11:27 LICENSE
-rw-r--r-- 1 root root   1263409 Sep 12 11:27 open_source_license
-rwxr-xr-x 1 root root     36337 Sep 12 11:27 prepare

[root@docker-server-node1 harbor]# ./prepare
......

[root@docker-server-node1 harbor]# ./install.sh
......

從 Harbor 部署好的樣子:

5.3 在主 Harbor 默認的 library 參考添加復制規(guī)則

從 harbor 的 library 倉庫,與主 harbor 倉庫名稱 library 一致。當然,
也可以創(chuàng)建新的倉庫,主從的倉庫名保持一致即可。

在主 Harbor Server2:192.168.100.19 的倉庫管理添加從 Harbor 作為目標:
在主 Harbor Server2:192.168.100.19 的 library 添加復制規(guī)則:

5.4 在從 harbor 倉庫下載鏡像使用

從 Harbor 上將同步的 alpine 鏡像 pull 下來測試

[root@docker-server-node1 ~]# docker pull 192.168.100.10/library/alpine:latest
latest: Pulling from library/alpine
c9b1b535fdd9: Already exists
Digest: sha256:ddba4d27a7ffc3f86dd6c2f92041af252a1f23a8e742c90e6e1297bfa1bc0c45
Status: Downloaded newer image for 192.168.100.10/library/alpine:latest
192.168.100.10/library/alpine:latest

[root@docker-server-node1 ~]# docker images | grep alpine
192.168.100.10/library/alpine                  latest              e7d92cdc71fe        5 weeks ago         5.59MB
...

[root@docker-server-node1 ~]# docker run -it --rm 192.168.100.10/library/alpine:latest sh
/ # cat /etc/issue
Welcome to Alpine Linux 3.11
Kernel \r on an \m (\l)

/ #

六.實現(xiàn) harbor 雙向同步

在從 Harbor(192.168.100.10)創(chuàng)建復制規(guī)則,將上傳到從 Harbor 的鏡像同步到
主 Harbor(192.168.100.19),兩邊都在 library 倉庫創(chuàng)建復制規(guī)則。

6.1 在 docker 客戶端導入 centos 基礎鏡像

在從 Harbor 的 docker 導入 centos 鏡像,用于同步準備

[root@docker-server-node1 ~]# docker load -i /opt/centos-latest-image.tar.gz
0683de282177: Loading layer [==================================================>]  244.9MB/244.9MB
Loaded image: centos:latest
[root@docker-server-node1 ~]# docker images
REPOSITORY                                     TAG                 IMAGE ID            CREATED             SIZE
centos                                         latest              470671670cac        5 weeks ago         237MB
...

6.2 貼 tag

[root@docker-server-node1 ~]# docker tag centos:latest 192.168.100.10/library/centos:latest

[root@docker-server-node1 ~]# docker images | grep centos
192.168.100.10/library/centos                  latest              470671670cac        5 weeks ago         237MB
centos                                         latest              470671670cac        5 weeks ago         237MB

6.3 上傳到從 harbor

[root@docker-server-node1 ~]# docker push 192.168.100.10/library/centos:latest
The push refers to repository [192.168.100.10/library/centos]
0683de282177: Pushed
latest: digest: sha256:9e0c275e0bcb495773b10a18e499985d782810e47b4fce076422acb4bc3da3dd size: 529

6.4 在從 harbor 創(chuàng)建同步規(guī)則

規(guī)則方式與主 harbor 相同,寫對方的 IP+用戶名密碼,然后點測試連接,確認可
以測試連接通過。

同樣,創(chuàng)建規(guī)則時的目標要到倉庫管理項去配置:新建目標文章來源地址http://www.zghlxwxcb.cn/news/detail-661700.html

6.5 docker 端測試

[root@docker-server-node2 harbor]# docker images | grep centos
[root@docker-server-node2 harbor]# docker pull 192.168.100.19/library/centos:latest
latest: Pulling from library/centos
8a29a15cefae: Pull complete
Digest: sha256:9e0c275e0bcb495773b10a18e499985d782810e47b4fce076422acb4bc3da3dd
Status: Downloaded newer image for 192.168.100.19/library/centos:latest
192.168.100.19/library/centos:latest
[root@docker-server-node2 harbor]# docker run --rm -it 192.168.100.19/library/centos:latest bash
[root@63e4aa284f50 /]# cat /etc/issue
\S
Kernel \r on an \m


6.8 harbor https 配置

# openssl genrsa -out /usr/local/src/harbor/certs/harbor-ca.key 2048
# openssl req -x509 -new -nodes -key /usr/local/src/harbor/certs/harbor-ca.key  -subj "/CN=harbor.suosuoli.local -days 7120 -out /usr/local/src/harbor/certs/harbor-ca.crt

# vim harbor.cfg
  hostname = harbor.suosuoli.local
  ui_url_protocol = https
  ssl_cert = /usr/local/src/harbor/certs/harbor-ca.crt
ssl_cert_key = /usr/local/src/harbor/certs/harbor-ca.key
harbor_admin_password = stevenux
# ./install.sh
# yum install docker-ce-18.06.3.ce-3.el7.x86_64.rpm
# yum install docker-compose
# mkdir /etc/docker/certs.d/harbor.suosuoli.local -p
# cp certs/harbor-ca.crt  /etc/docker/certs.d/harbor.suosuli.local/
# docker login harbor.suosuoli.local

到了這里,關于Docker分布式倉庫的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • Docker部署ZooKeeper分布式協(xié)調(diào)服務

    1、準備工作 2、創(chuàng)建TEST容器,將conf目錄COPY出來,在映射進去,方便后續(xù)維護管理! 3、運行容器 4、測試鏈接zookeeper 正常輸出內(nèi)容:

    2024年02月07日
    瀏覽(24)
  • Hadoop完全分布式安裝基于Docker

    Hadoop完全分布式安裝基于Docker

    (都在root用戶下) 在Dockfile文件中添加以下內(nèi)容 基于centos鏡像,生成帶有spenssh-server、openssh-clients的鏡像,用戶為root,密碼為a123456,鏡像維護者(作者)為hadoop 建好Dockerfile文件后,生成鏡像,在終端輸入: 1、在主機下載ssh 2、把hadoop和jdk傳到/root 3、解壓hadoop和jdk 4、生成帶

    2024年04月29日
    瀏覽(20)
  • 使用Docker構建分布式應用程序

    作者:禪與計算機程序設計藝術 Docker是一個開源的應用容器引擎,讓開發(fā)者可以打包他們的應用以及依賴包到一個輕量級、可移植的容器中,然后發(fā)布到任何流行的Linux或Windows機器上,也可以實現(xiàn)虛擬化。 傳統(tǒng)的應用分為三層結構:應用運行環(huán)境、應用邏輯和資源管理,Doc

    2024年02月08日
    瀏覽(104)
  • 【Docker】Docker+Zipkin+Elasticsearch+Kibana部署分布式鏈路追蹤

    【Docker】Docker+Zipkin+Elasticsearch+Kibana部署分布式鏈路追蹤

    點擊跳轉:Docker安裝MySQL、Redis、RabbitMQ、Elasticsearch、Nacos等常見服務全套(質量有保證,內(nèi)容詳情) 本文主要討論在Elasticsearch和Kibana安裝好合適版本的前提下,繼續(xù)整合Zipkin。 一般的,它們的工作過程是這樣的:Spring Cloud微服務把調(diào)用鏈路的日志發(fā)送給Zipkin,Zipkin把數(shù)據(jù)發(fā)

    2024年02月14日
    瀏覽(29)
  • 基于 Docker 搭建 Hadoop 分布式及 Docker 基本操作使用

    基于 Docker 搭建 Hadoop 分布式及 Docker 基本操作使用

    Docker的整個生命周期有三部分組成:鏡像(image)+容器(container)+倉庫(repository)簡單來講,鏡像是文件,容器是進程容器是基于鏡像創(chuàng)建的,即容器中的進程依賴于鏡像中的文件,在Docker的生命周期中,最核心的兩個部分,一個是鏡像 (Images),一個是容器 (Containers)。 鏡像

    2024年02月11日
    瀏覽(29)
  • 基于Docker搭建hdfs分布式實驗環(huán)境

    理論知識 Docker Docker 是一個開源的應用容器引擎,基于?Go 語言?并遵從 Apache2.0 協(xié)議開源。Docker 可以讓開發(fā)者打包他們的應用以及依賴包到一個輕量級、可移植的容器中,然后發(fā)布到任何流行的 Linux 機器上,也可以實現(xiàn)虛擬化。容器是完全使用沙箱機制,相互之間不會有任

    2023年04月08日
    瀏覽(18)
  • 基于Docker的JMeter分布式壓測

    基于Docker的JMeter分布式壓測

    目錄 前言: Docker Docker在JMeter分布式測試中的作用 Dockerfile用于JMeter基礎: Dockerfile for JMeter Server / Slave: 總結 前言: ? ? ? ? 基于Docker的JMeter分布式壓測是一種將JMeter測試分布在多個容器中進行的方法,可以提高測試的性能和效率。使用Docker容器化JMeter,可以輕松地在多個主

    2024年02月11日
    瀏覽(20)
  • 利用 docker 實現(xiàn)JMeter分布式壓測

    利用 docker 實現(xiàn)JMeter分布式壓測

    在工作中經(jīng)常需要對一些關鍵接口做高QPS的壓測,JMeter是由Java 語言開發(fā),沒創(chuàng)建一個線程(虛擬用戶),JVM默認會為每個線程分配1M的堆棧內(nèi)存空間。受限于單臺試壓機的配置很難實現(xiàn)太高的并發(fā)。所以,通過JMeter實現(xiàn)分布式,可以整合多臺主機的硬件資源,實現(xiàn)同時對被測

    2024年02月05日
    瀏覽(31)
  • 基于docker實現(xiàn)JMeter分布式壓測

    基于docker實現(xiàn)JMeter分布式壓測

    在工作中經(jīng)常需要對一些關鍵接口做高QPS的壓測,JMeter是由Java 語言開發(fā),沒創(chuàng)建一個線程(虛擬用戶),JVM默認會為每個線程分配1M的堆棧內(nèi)存空間。受限于單臺試壓機的配置很難實現(xiàn)太高的并發(fā)。所以,通過JMeter實現(xiàn)分布式,可以整合多臺主機的硬件資源,實現(xiàn)同時對被測

    2024年02月07日
    瀏覽(23)
  • 使用 Docker 部署分布式存儲系統(tǒng)——Ceph

    使用 Docker 部署分布式存儲系統(tǒng)——Ceph

    最近工作中接觸了一個 Python + Flask 的新項目,項目中使用了 Ceph 對象存儲服務。遂在開發(fā)環(huán)境使用 Docker 搭建了一套 Ceph 集群。 Ceph 官方文檔 Ceph 是一個開源的分布式存儲系統(tǒng),提供了對象存儲、塊存儲和文件系統(tǒng)三種存儲接口。Ceph 將數(shù)據(jù)存儲在邏輯存儲池中,使用 CRUSH 分

    2024年04月15日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包