环境

IP备注
192.168.1.10docker、harbor
192.168.1.20docker、harbor

告知master、slave机器都需要在安装docker、docker-compose、harbor,
然后master下载nginx镜像修改tag标签进行上传到私有仓库
尝试master-harbor远程复制slave-harbor
成功~

修改主机名、免密登录

[root@localhost ~]# hostname master
[root@localhost ~]# bash
[root@master ~]# 
[root@localhost ~]# hostname slave
[root@localhost ~]# bash
[root@slave ~]# 

master

echo '192.168.1.20 slave' >> /etc/hosts
[root@master ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:sBcmGls3wHzdl9qio/mjFuBvq1s5P4XaqHNkHypqTv4 root@master
The key's randomart image is:
+---[RSA 2048]----+
|     o.  . .   . |
|      o.. . . o  |
|    . +.=    +   |
|     =.* o  o .  |
|    o...S  o .   |
|      ..+.= .    |
|    .  ++X +     |
|   o. o.@o=      |
|   o+oEXo+oo     |
+----[SHA256]-----+
[root@master ~]# ssh-copy-id -i slave
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host 'slave (192.168.1.20)' can't be established.
ECDSA key fingerprint is SHA256:dnnDcAA2qVnA31i7mtr9LYJmH2veu2+r4t+19qUSqqw.
ECDSA key fingerprint is MD5:0e:f3:c1:3c:dc:5f:12:66:ae:c9:01:51:66:db:bb:02.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@slave's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'slave'"
and check to make sure that only the key(s) you wanted were added.
## 测试登录
[root@master ~]# ssh slave
Last login: Fri Dec 25 09:17:17 2020 from 192.168.1.250
[root@slave ~]# exit
登出
Connection to slave closed.

master、slave安装docker、harbor

yum -y install yum-utils
yum-config-manager     --add-repo     https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo     
yum -y install docker-ce
[root@master ~]# systemctl start docker
[root@master ~]# docker --version
Docker version 20.10.1, build 831ebea

安装docker-compose工具、harbor仓库

[root@master bin]# chmod +x docker-compose 
[root@master bin]# docker-compose -version
docker-compose version 1.25.4, build 8d51620a
[root@master ~]# tar -zxf harbor-offline-installer-v1.6.3.tgz 
[root@master ~]# cd harbor
[root@master harbor]# vi harbor.cfg 
7行 hostname = 192.168.1.10  #修改自己的ip
[root@slave harbor]# vi harbor.cfg
7行 hostname = 192.168.1.20  #修改自己的ip
[root@master harbor]# ./install.sh  ##进行安装

修改docker配置文件添加仓库地址

[root@master harbor]# vim /usr/lib/systemd/system/docker.service
     13行 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.1.10  #添加地址
[root@master harbor]# systemctl daemon-reload && systemctl restart docker

查看harbor服务状态

docker ps -a
查看是否都是正常状态
如果不是重新发布
[root@master harbor]# docker-compose down
[root@master harbor]# docker-compose up -d
测试登录
[root@master harbor]# docker login 192.168.1.10
Username: admin
Password: 默认密码Harbor12345
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

访问

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

测试上传镜像

docker tag SOURCE_IMAGE[:TAG] 192.168.1.10/test/IMAGE[:TAG]
docker push 192.168.1.10/test/IMAGE[:TAG]

[root@master harbor]# docker pull nginx
[root@master harbor]# docker tag  nginx:latest 192.168.1.10/test/nginx:latest
[root@master harbor]# docker push 192.168.1.10/test/nginx:latest
The push refers to repository [192.168.1.10/test/nginx]
4eaf0ea085df: Pushed 
2c7498eef94a: Pushed 
7d2b207c2679: Pushed 
5c4e5adc71a8: Pushed 
87c8a1d8f54f: Pushed 
latest: digest: sha256:13e4551010728646aa7e1b1ac5313e04cf75d051fa441396832fcd6d600b5e71 size: 1362

页面查看

在这里插入图片描述

远程同步

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

slave的harbor仓库成功复制

在这里插入图片描述

GitHub 加速计划 / ha / harbor
23.24 K
4.68 K
下载
Harbor 是一个开源的容器镜像仓库,用于存储和管理 Docker 镜像和其他容器镜像。 * 容器镜像仓库、存储和管理 Docker 镜像和其他容器镜像 * 有什么特点:支持多种镜像格式、易于使用、安全性和访问控制
最近提交(Master分支:2 个月前 )
9e55afbb pull image from registry.goharbor.io instead of dockerhub Update testcase to support Docker Image Can Be Pulled With Credential Change gitlab project name when user changed. Update permissions count and permission count total Change webhook_endpoint_ui Signed-off-by: stonezdj <stone.zhang@broadcom.com> Co-authored-by: Wang Yan <wangyan@vmware.com> 10 天前
3dbfd422 Signed-off-by: wang yan <wangyan@vmware.com> 10 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐