前言
离线安装docker环境,离线安装Harbor仓库
一、离线安装包
docker安装包地址:https://download.docker.com/linux/static/stable/x86_64/
docker-compose安装包地址:https://github.com/docker/compose/releases
harbor安装包地址:https://github.com/goharbor/harbor/releases
二、安装步骤
1.安装docker
-
解压安装包
[root@hk134 home]# tar -xzvf docker-19.03.9.tgz
- 拷贝到/usr/bin下
[root@hk134 home]# cp docker/* /usr/bin/
- 创建并编辑docker.service文件
[root@hk134 home]# vi /etc/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
- 添加权限
[root@hk134 home]# chmod +x /etc/systemd/system/docker.service
- 重新加载服务配置文件
[root@hk134 home]# systemctl daemon-reload
[root@hk134 home]# systemctl enable docker.service
- 启动docker
[root@hk134 home]# systemctl start docker
- 查看docker状态
[root@hk134 home]# systemctl status docker
2.安装docker-compose
-
将安装包移动到/usr/bin目录下,并修改名称
[root@hk134 home]# sudo mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
- 修改权限
[root@hk134 home]# sudo chmod a+x /usr/local/bin/docker-compose
- 查看版本
[root@hk134 home]# docker-compose -v
docker-compose version 1.27.4, build 40524192
3.安装Harbor
-
解压安装包
[root@hk134 home]# tar -xzvf harbor-offline-installer-v2.1.1.tgz -C /opt/
- 修改文件名
[root@hk134 home]# cp /opt/harbor/harbor.yml.tmpl /opt/harbor/harbor.yml
- 修改配置文件harbor.yml,hostname修改为IP或者域名,注释掉https相关配置
[root@hk134 home]# vi /opt/harbor/harbor.yml
- 解压镜像
[root@hk134 home]# docker load -i /opt/harbor/harbor.v2.1.1.tar.gz
- 执行准备程序
[root@hk134 home]# bash /opt/harbor/prepare
- 执行安装程序
[root@hk134 home]# bash /opt/harbor/install.sh
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry ... done
Creating harbor-db ... done
Creating registryctl ... done
Creating harbor-portal ... done
Creating redis ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----
- 查看docker-compose状态
[root@hk134 harbor]# docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------
harbor-core /harbor/entrypoint.sh Up (healthy)
harbor-db /docker-entrypoint.sh Up (healthy)
harbor-jobservice /harbor/entrypoint.sh Up (healthy)
harbor-log /bin/sh -c /usr/local/bin/ ... Up (healthy) 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up (healthy)
nginx nginx -g daemon off; Up (healthy) 0.0.0.0:80->8080/tcp
redis redis-server /etc/redis.conf Up (healthy)
registry /home/harbor/entrypoint.sh Up (healthy)
registryctl /home/harbor/start.sh Up (healthy)
- 通过IP访问web页面
4、可能出现的问题
[root@hk134 home]# docker-compose ps
ERROR:
Can't find a suitable configuration file in this directory or any
parent. Are you in the right directory?
Supported filenames: docker-compose.yml, docker-compose.yaml
处理方式:
[root@hk134 harbor]# docker-compose -f /opt/harbor/docker-compose.yml down -v
Stopping harbor-jobservice ... done
Stopping nginx ... done
Stopping harbor-core ... done
Stopping harbor-db ... done
Stopping registryctl ... done
Stopping registry ... done
Stopping harbor-portal ... done
Stopping redis ... done
Stopping harbor-log ... done
Removing harbor-jobservice ... done
Removing nginx ... done
Removing harbor-core ... done
Removing harbor-db ... done
Removing registryctl ... done
Removing registry ... done
Removing harbor-portal ... done
Removing redis ... done
Removing harbor-log ... done
Removing network harbor_harbor
[root@hk134 harbor]# docker-compose -f /opt/harbor/docker-compose.yml up -d
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry ... done
Creating harbor-portal ... done
Creating redis ... done
Creating harbor-db ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done