harbor镜像仓库主从配置

master :192.168.53.9

slave :192.168.53.10

docker安装 略

docker-compose下载地址:https://github.com/docker/compose/releases/

harbor版本:v2.1.0

下载地址:https://github.com/goharbor/harbor/releases

docker-compose安装

#wget https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64
#mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
#chmod +x /usr/bin/docker-compose
# docker-compose -v
docker-compose version 1.27.4, build 40524192

harbor离线安装

# tar xf harbor-offline-installer-v2.1.0.tgz
#cd harbor/
# ll
total 545264
-rw-r--r--. 1 root root      3361 Sep 15 19:48 common.sh
-rw-r--r--. 1 root root 558317240 Sep 15 19:49 harbor.v2.1.0.tar.gz
-rw-r--r--. 1 root root      8136 Sep 15 19:48 harbor.yml.tmpl
-rwxr-xr-x. 1 root root      2523 Sep 15 19:48 install.sh
-rw-r--r--. 1 root root     11347 Sep 15 19:48 LICENSE
-rwxr-xr-x. 1 root root      1881 Sep 15 19:48 prepare
# cp harbor.yml.tmpl harbor.yml
# vim harbor.yml
... # Configuration
file of Harbor # The IP address or hostname to access admin UI and registry service. # DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients. hostname: 192.168.53.9 内网访问IP即可,也可设置域名 # http related config http: # port for http, default is 80. If https enabled, this port will redirect to https port port: 80 # https related config #https: 不使用https访问,注释掉 # https port for harbor, default is 443 # port: 443 # The path of cert and key files for nginx # certificate: /your/certificate/path # private_key: /your/private/key/path ...

导入镜像并安装

#docker load < harbor.v2.1.0.tar.gz
#./install.sh

 修改docker.service文件

vim /usr/lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd --insecure-registry 192.168.53.9

重启docker服务

systemctl daemon-reload
systemctl restart docker

从主机执行相同操作

页面访问,创建项目

主从配置

服务器登录测试镜像推送,并查看是否同步

1)登录
# docker login -u admin -p Harbor12345 192.168.53.9
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
2)pull镜像
3)镜像打tag
# docker tag nginx:latest 192.168.53.9/demon/nginx:v1

4)推送镜像到harbor仓库
# docker push 192.168.53.9/demon/nginx:v1

5)登录harbor仓库验证

同步完成

原文地址:https://www.cnblogs.com/goujinyang/p/13823367.html