当前位置 : 主页 > 操作系统 > centos >

Docker Harbor私有仓库安装部署

来源:互联网 收集:自由互联 发布时间:2022-06-20
Docker harbor的官网地址: https://github.com/goharbor/harbor Docker harbor安装包下载地址: https://github.com/goharbor/harbor/releases/download/v2.3.2/harbor-online-installer-v2.3.2.tgz 安装harbor的依赖要求: 安装harbor的主

Docker harbor的官网地址:

https://github.com/goharbor/harbor

Docker harbor安装包下载地址:

https://github.com/goharbor/harbor/releases/download/v2.3.2/harbor-online-installer-v2.3.2.tgz

安装harbor的依赖要求:

Docker Harbor私有仓库安装部署_Docker Harbor私有仓库安装部

安装harbor的主机硬件要求:

Docker Harbor私有仓库安装部署_Docker Harbor私有仓库安装部_02

下载harbor软件包并解压:

tar zxf harbor-online-installer-v2.3.2.tgz cp harbor.yml.tmpl harbor.yml mkdir cert #用于存放证书

编辑harbor.yml配置文件主要修改一下三行:

[root@harbor harbor]# cat harbor.yml | grep -v '^#' | grep -v "^.* #" | grep -v "^$" hostname: testharbor.sit.51zhaoyou.com http: port: 80 https: port: 443 certificate: /harbor/harbor/cert/4936059__sit.51zhaoyou.com.pem private_key: /harbor/harbor/cert/4936059__sit.51zhaoyou.com.key

 

修改配置文件后,先运行,使配置文件生效:

./prepare

 

报错:Docker没有安装:

Docker Harbor私有仓库安装部署_docker_03

安装docker 的依赖:

yum install -y yum-utils device-mapper-persistent-data lvm2

 

安装阿里的docker yum源:

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

 

安装docker

yum install -y docker-ce docker-ce-cli containerd.io

 

再次运行生效配置文件:

./prepare

 

提示docker没有运行:

[root@harbor harbor]# ./prepare prepare base dir is set to /harbor/harbor docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See 'docker run --help'. [root@harbor harbor]# systemctl restart docker && systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/syste

Docker Harbor私有仓库安装部署_docker_04

启动docker:

systemctl start docker && systemctl enable docker

 

再次运行安装完成:

./prepare

Docker Harbor私有仓库安装部署_harbor_05

 

运行安装脚本

./install.sh

 

报错提示需要安装docker-compose版本1.18.0以上版本:

yum install epel-release -y yum install docker-compose –y [root@harbor harbor]# ./install.sh [Step 0]: checking if docker is installed ... Note: docker version: 20.10.8 [Step 1]: checking docker-compose is installed ... ✖ Need to install docker-compose(1.18.0+) by yourself first and run this script again.

Docker Harbor私有仓库安装部署_harbor_06

 

再次运行安装脚本:

./install.sh

运行安装脚本时间比较久,会下载很多docker镜像

Docker Harbor私有仓库安装部署_harbor_07

可以查看下启动的镜像:

# docker ps

Docker Harbor私有仓库安装部署_Docker Harbor私有仓库安装部_08

Linux主机加个解析:

192.168.1.19    testharbor.sit.51zhaoyou.com

本地window主机加个解析:

192.168.1.19    testharbor.sit.51zhaoyou.com

浏览器测试访问harbor:

https://testharbor.sit.51zhaoyou.com

Docker Harbor私有仓库安装部署_docker_09

账号密码harbor.yml配置文件有写:

admin  Harbor12345

docker配置daemon.json指明安全仓库位置:

[root@harbor log]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://v16stybc.mirror.aliyuncs.com"], "insecure-registries": ["https://testharbor.sit.51zhaoyou.com"], "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size":"100m" } }

 

本地测试登录仓库:

[root@harbor harbor]# docker login testharbor.sit.51zhaoyou.com

Docker Harbor私有仓库安装部署_Docker Harbor私有仓库安装部_10

登录报错,可能是因为重启docker导致harbor服务down,重启harbor即可。

[root@harbor log]# docker login testharbor.sit.51zhaoyou.com Username: admin Password: Error response from daemon: Get "http://testharbor.sit.51zhaoyou.com/v2/": dial tcp 192.168.1.19:80: connennection refused

解决办法:

启动关闭harbor:

docker-compose down -v docker-compose up -d



上一篇:Prometheus监控运维实战九:告警规则
下一篇:没有了
网友评论