创建harbor服务器
OS:Centos 8.2
Harbor version: v2.5.0
docker-compose version:v2.5.0
1.修改计算机名称
hostnamectl set-hostname harbor && bash
2.创建自签名证书
mkdir -p /data/ssl
cd /data/ssl
openssl genrsa -out ca.key 3072
openssl req -new -x509 -days 3650 -key ca.key -out ca.pem
openssl genrsa -out harbor.key 3072
openssl req -new -key harbor.key -out harbor.csr
openssl x509 -req -in harbor.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out harbor.pem -days 3650
3.基础准备
systemctl disable firewalld --now
yum install -y iptables-services
systemctl disable iptables --now
iptables -F
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
setenforce 0
yum install -y ntp ntpdate
crontab -e
* */1 * * * /usr/sbin/ntpdate ntp1.aliyum.com
systemctl restart crond
4.安装基础软件包
yum install -y wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo libaio-devel wget vim ncurses-devel autoconf automake zlib-devel python-devel epel-release openssh-server socat ipvsadm conntrack
5.配置docker-ce的yum源
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
6.安装docker-ce
yum install -y docker-ce
7.启动docker服务
systemctl enable docker --now
8.开启包转发功能和修改内核参数
modprobe br_netfilter
cat > /etc/sysctl.d/docker.conf <<END
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
END
sysctl -p /etc/sysctl.d/docker.conf
cat > /etc/rc.sysinit <<END
#/bin/bash
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
END
cd /etc/sysconfig/modules/
cat > br_netfilter.modules <<END
modprobe br_netfilter
END
chmod 755 br_netfilter.modules
systemctl restart docker
9.配置镜像加速器
cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://5vrctq3v.mirror.aliyuncs.com","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com"]
}
systemctl daemon-reload
systemctl restart docker
10.准备harbor
mkdir /data/install -p
cd /data/install
#把harbor的离线包harbor-offline-installer-v2.5.0.tgz上传到这个目录
下载harbor离线包的地址:
https://github.com/goharbor/harbor/releases/tag
tar -zxvf harbor-offline-installer-v2.5.0.tgz
cd harbor
cp harbor.yml.tmpl harbor.yml
修改harbor.yml如下内容
11.安装docker compose
上传安装包docker-compose-linux-x86_64到/data/install/harbor
下载地址https://github.com/docker/compose/releases
mv docker-compose-linux-x86_64 /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
12.安装harbor
cd /data/install/harbor
./install.sh
看到下面说明安装成功了
13.浏览器打开harbor
windows里可在hosts中做好解析,或者使用DNS作解析,我这里harbor.xxx.top 已和192.168.1.181做好对应。
14.修改/etc/docker/daemon.json
systemctl daemon-reload && systemctl restart docker
这步骤是在harbor客户端上做,不是在服务端做,哪台机要login harbor,哪台机上要做
15.login harbor并上传镜像
docker login 192.168.1.181
admin #默认用户名
Harbor12345 #默认密码
16.从私有docker harbor下载镜像
首先本地删除镜像
下载镜像