安装harbor前要优先安装docker以及docker-compose
1. 查看操作系统
nkvers
2. 安装docker(离线安装)
2.1 下载docker资源
Index of linux/static/stable/x86_64/
2.2 指定目录下解压
cd /opt
tar –zxvf docker-20.10.0.tgz
cd /opt/docker
2.3 将docker中的全部文件,使用下边命令,复制到/usr/bin
cp ./* /usr/bin
2.4 docker.service 文件
新建docker.service文件
cd /etc/systemd/system
touch docker.service
编辑 docker.service
vi docker.service
注意,将其中的ip地址,改成您的服务器地址,其它参数不用改。
--insecure-registry=10.105.0.99(之后harbor的地址)
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=10.105.0.99
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
增加可执行权限
chmod +x docker.service
可以查看配置:docker info
2.5 重新加载配置后启动
systemctl deamon-reload
systemctl start docker
查看docker 状态
systemctl status docker
查看docker版本
docker –v
2.6 设置开机自启动
systemctl enable docker.service
3. 安装docker-compose
3.1 下载docker-compose
加速下载(可以修改版本)
3.2 重命名为docker-compose
cp ./docker-compose-linux-x86_64 ./docker-compose
3.3 放入服务器指定目录
mv docker-compose /usr/local/bin/
3.4 增加可执行权限
chmod +x /usr/local/bin/docker-compose
docker-compose -v //查看版本
docker-compose环境准备完毕!
4. 安装harbor
4.1 外网下载所需要的docker
可以修改版本号下载别的版本
4.2 上传到服务器指定目录解压
cd /opt
tar –zxvf harbor-offline-installer-v2.7.0.tgz
4.3 重命名harbor.yml.tmpl
mv harbor.yml.tmpl harbor.yml
4.4 编辑harbor.yml
修改hostname以及端口,注释掉https相关配置,也可根据自己需要修改数据和日志存放目录以及admin登录密码
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 10.105.0.99
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80
# https related config
#https:
# https port for harbor, default is 443
#port: 443
# The path of cert and key files for nginx
#certificate: /data/cert/registry.harbor.com.crt
#private_key: /data/cert/registry.harbor.com.key
保存退出
执行./prepare
(修改common权限777)
因为我自己安装时harbor后启动时,nginx以及registry状态一直是restarting,修改权限后重新install才正常
4.5 执行安装
./install.sh
安装成功后会自动启动
查看harbor安装情况
docker-compose ps
4.6 浏览器访问harbor
4.7 docker登录harbor
执行命令:
docker login 10.105.0.99
依次输入harbor用户名密码
4.8 harbor配置代理(看自己是否需要)
如果harbor需要配置代理,可以修改harbor.yml文件
#重启harbor组件镜像包:
docker-compose down -v
docker-compose up -d