目录
一、安装docker编排工具docker compose
二、安装Harbor软件包
三、修改配置文件
四、运行安装脚本
五、安装后验证
六、使用Harbor
一、安装docker编排工具docker compose
在github上选择自己想要的版本下载
https://github.com/docker/compose/releases
下载好之后传送到Linux主机上
#将文件改名并移动到/usr/local/bin目录下
[root@client ~]# mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
[root@client ~]# ll /usr/local/bin/
total 59056
-rw-r--r-- 1 root root 60470973 Aug 19 13:14 docker-compose
#添加可执行权限
[root@client ~]# cd /usr/local/bin
[root@client bin]# chmod +x docker-compose
#执行命令能查看到版本,则安装成功
[root@client bin]# docker-compose version
Docker Compose version v2.20.2
二、安装Harbor软件包
在github上下载离线安装软件包
https://github.com/goharbor/harbor/releases
#将下载的压缩包解压到/usr/local目录下
[root@client ~]# tar xf harbor-offline-installer-v2.8.4.tgz -C /usr/local/
#可以看到多了个harbor目录
[root@client ~]# cd /usr/local/
[root@client local]# ls
bin etc games harbor include lib lib64 libexec sbin share src
#进入到harbor目录下,拷贝模板配置文件harbor.yml.tmpl
[root@client local]# cd harbor/
[root@client harbor]# ls
common.sh harbor.v2.8.4.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
[root@client harbor]# cp harbor.yml.tmpl harbor.yml
三、修改配置文件
拷贝模板配置文件之后,再更改配置文件,hostname可以用自己的主机名代替,暂时不要https加密,就直接注释掉
[root@client harbor]# vim harbor.yml
#确保主机名与配置文件当中添加的hostname一致
[root@client ~]# hostnamectl set-hostname example.client.com
[root@client ~]# hostname
example.client.com
然后默认的harbor管理员密码以及数据库密码,可以根据自己需求来更改,其他就没必要改了
四、运行安装脚本
#直接运行install.sh这个脚本即可
[root@client harbor]# ls
common.sh harbor.v2.8.4.tar.gz harbor.yml harbor.yml.tmpl install.sh LICENSE prepare
[root@client harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 24.0.5
[Step 1]: checking docker-compose is installed ...
Note: Docker Compose version v2.20.2
[Step 2]: loading Harbor images ...
a074a02dfff1: Loading layer [==================================================>] 37.79MB/37.79MB
a1845a3d89a2: Loading layer [==================================================>] 9.188MB/9.188MB
3f06bc32288c: Loading layer [==================================================>] 3.584kB/3.584kB
245244bd15d4: Loading layer [==================================================>] 2.56kB/2.56kB
.......
...
最后会显示安装和启动成功
五、安装后验证
可以看到打开了一些端口
[root@client harbor]# ss -lntup | grep docker
tcp LISTEN 0 128 *:80 *:* users:(("docker-proxy",pid=10845,fd=4))
tcp LISTEN 0 128 127.0.0.1:1514 *:* users:(("docker-proxy",pid=10151,fd=4))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("docker-proxy",pid=10862,fd=4))
harbor实际就是启动了一些docker服务
[root@client harbor]# docker-compose ls
NAME STATUS CONFIG FILES
harbor running(9) /usr/local/harbor/docker-compose.yml
[root@client harbor]#
[root@client harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f1bd03f390e7 goharbor/harbor-jobservice:v2.8.4 "/harbor/entrypoint.…" 10 minutes ago Up 9 minutes (healthy) harbor-jobservice
77f84a1b3072 goharbor/nginx-photon:v2.8.4 "nginx -g 'daemon of…" 10 minutes ago Up 10 minutes (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp nginx
9c5714f4519e goharbor/harbor-core:v2.8.4 "/harbor/entrypoint.…" 10 minutes ago Up 10 minutes (healthy) harbor-core
ad3dab433452 goharbor/harbor-registryctl:v2.8.4 "/home/harbor/start.…" 10 minutes ago Up 10 minutes (healthy) registryctl
e4c6e309926b goharbor/harbor-portal:v2.8.4 "nginx -g 'daemon of…" 10 minutes ago Up 10 minutes (healthy) harbor-portal
143f478b3630 goharbor/redis-photon:v2.8.4 "redis-server /etc/r…" 10 minutes ago Up 10 minutes (healthy) redis
aa2ee3e8b745 goharbor/harbor-db:v2.8.4 "/docker-entrypoint.…" 10 minutes ago Up 10 minutes (healthy) harbor-db
f738736580c1 goharbor/registry-photon:v2.8.4 "/home/harbor/entryp…" 10 minutes ago Up 10 minutes (healthy) registry
b3a243342269 goharbor/harbor-log:v2.8.4 "/bin/sh -c /usr/loc…" 10 minutes ago Up 10 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
六、使用Harbor
浏览器输入:主机ip/account/sign-in
然后就进入登录页面了,用户是admin,密码是刚才在配置文件harbor.yml里面自己修改的密码,我是默认的没有修改
然后成功登录进来,就可以使用了