Docker Harbor私有仓库安装部署
Posted 青衫解衣
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker 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的依赖要求:
安装harbor的主机硬件要求:
下载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 的依赖:
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:
systemctl start docker && systemctl enable docker
再次运行安装完成:
./prepare
运行安装脚本
./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.
再次运行安装脚本:
./install.sh
运行安装脚本时间比较久,会下载很多docker镜像
可以查看下启动的镜像:
# docker ps
Linux主机加个解析:
192.168.1.19 testharbor.sit.51zhaoyou.com
本地window主机加个解析:
192.168.1.19 testharbor.sit.51zhaoyou.com
浏览器测试访问harbor:
https://testharbor.sit.51zhaoyou.com
账号密码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服务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
以上是关于Docker Harbor私有仓库安装部署的主要内容,如果未能解决你的问题,请参考以下文章