之前我有写过如何搭建harbor以及配置harbor,本文主要讲一下在不联网的情况下如何搭建Harbor平台。
环境:centos 7.9
docker版本:20.10.17
harbor版本:v1.10.10
一、离线安装docker
安装包官方地址:Index of linux/static/stable/x86_64/
1.找一台联网机器下载:
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.17.tgz
2.将下载的压缩包拷贝到目标服务器后解压:
tar zxf docker-20.10.17.tgz
3.将解压出来的docker文件复制到/usr/bin/目录下
cp docker/* /usr/bin/
4.创建docker.service文件
vi /usr/lib/systemd/system/docker.service
[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 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 |
5. 启动docker
给docker.service文件添加执行权限:
chmod +x /usr/lib/systemd/system/docker.service
重新加载配置文件:
systemctl daemon-reload
启动docker并将docker加入开机自启动:
systemctl start docker
systemctl enable docker
6.查看docker服务状态:
systemctl status docker
docker info
docker version
二、离线安装docker-compose
1.在任意联网的centos机器上安装:
curl -L https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-`uname -s`-`uname -m` > /usr/local/share/docker-compose
2.将docker-compose拷贝到目标机器的/usr/bin目录下
3.对docker-compose赋可执行权限:chmod +x /usr/bin/docker-compose
三、离线安装harbor
1. 下载v1.10.10的离线安装包:
Release v1.10.10 · goharbor/harbor · GitHub
2. 拷贝到目标服务器,并解压到/harbor目录
mkdir -p /harbor
tar zxf harbor-offline-installer-版本.tgz -C /harbor
3. 配置harbor.yml
修改hostname,如果不走https,则把https部分注释掉:
hostname: xx.xx.xx.xx #https: # https port for harbor, default is 443 # port: 443 # The path of cert and key files for nginx # certificate: /your/certificate/path # private_key: /your/private/key/path |
4. 运行harbor安装程序
./install.sh |
5.登录harbor
http://ip
6. 如何重启harbor
systemctl stop docker systemctl start docker docker-compose up -d |
7. 设置harbor开机自启动
编辑:vi /lib/systemd/system/harbor.service
[Unit] Description=Harbor After=docker.service systemd-networkd.service systemd-resolved.service Requires=docker.service Documentation=http://github.com/vmware/harbor [Service] Type=simple Restart=on-failure RestartSec=5 ExecStart=/usr/bin/docker-compose -f /harbor/harbor/docker-compose.yml up ExecStop=/usr/bin/docker-compose -f /harbor/harbor/docker-compose.yml down [Install] WantedBy=multi-user.target |
设置开机自启服务并启动harbor
systemctl enable harbor systemctl start harbor |