1. Install docker environment
Docker is already included in the default repository of CentOS 7, and you can install it directly using the yum command. However, in order to ensure that the latest version of Docker can be installed, we will use Docker's official repository for installation.
# 首先安装一些必要的包:
yum install -y yum-utils device-mapper-persistent-data lvm2
# 然后添加 Docker 仓库:
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安装 Docker
yum -y install docker-ce
# 启动 Docker 并设置开机启动
systemctl start docker
systemctl enable docker
# 验证docker安装
docker run hello-world
2. Docker-compose installation
# docker-compose安装包下载
curl -L "https://get.daocloud.io/docker/compose/releases/download/v1.25.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
mv ./docker-compose-linux-x86_64 /usr/local/bin/docker-compose
# 赋予执行权限
chmod +x /usr/local/bin/docker-compose
# 查看版本
docker-compose --version
3. Harbor installation
# harbor仓库安装包下载地址
https://github.com/goharbor/harbor/releases/download/v2.3.4/harbor-offline-installer-v2.3.4.tgz
tar -zxf harbor-offline-installer-v2.3.4.tgz -C /opt/
cd /opt/harbor
cp harbor.yml.tmpl harbor.yml
vi harbor.yml
# 开始安装
./install.sh
# 配置开机自启动
/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up -d
4. Harbor starting and stopping
# 启动harbor
systemctl start docker
cd /opt/harbor
docker-compose start
# 停止harbor
systemctl stop docker
cd /opt/harbor
docker-compose stop