1、安装harbor前需先安装docker和docker-compose:
安装docker
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install epel-release -y
yum install docker-ce python2-pip -y
安装 docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.3.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
给 docker-compose 授权
chmod +x /usr/local/bin/docker-compose
查看 docker-compose 版本
docker-compose -v
2、安装配置harbor:
(1)、下载 wget https://github.com/goharbor/harbor/releases/download/v2.4.2/harbor-offline-installer-v2.4.2.tgz
(2)、将下载的harbor解压到指定目录
tar xf harbor-offline-installer-v2.4.2.tgz -C /usr/local
(3)、配置
到harbor目录(/usr/local/harbor)修改配置(harbor.yml),如果harbor.yml不存在则将harbor.yml.tmpl复制为harbor.yml(cp harbor.yml.tmpl harbor.yml)
修改 hostname为当前服务器ip
修改harbor密码:harbor_admin_password
执行 ./install.sh,安装harbor,安装成功后 docker ps -a 可以看到
在docker服务器中上传镜像到harbor服务器:
1,在docker服务器中配置harbor服务器的ip(/etc/docker/daemon.json):
"insecure-registries": ["192.168.60.129"]
修改后需要重新加载daemon(systemctl daemon-reload)并重启(systemctl restart docker)
2,在docker服务器登录harbor服务器(用户名密码是harbor控制台的,用户名默认admin):
docker login 192.168.60.129
登出: docker logout 192.168.60.129
3,打标签(192.168.60.129为harbor服务器ip,v1为标签):
docker tag image_id 192.168.60.129/library/hello-world:v1
4,上传到harbor服务器:
docker push 192.168.60.129/library/hello-world:v1
5、从harbor服务器下载镜像:
docker pull 192.168.60.129/library/hello-world:v1