目录
Compose 项目是 Docker 官方的开源项目,负责实现对 Docker 容器集群的快速编排。使用前面介绍的Dockerfile我们很容易定义一个单独的应用容器。然而在日常开发工作中,经常会碰到需要多个容器相互配合来完成某项任务的情况。例如要实现一个 Web 项目,除了 Web 服务容器本身,往往还需要再加上后端的数据库服务容器;再比如在分布式应用一般包含若干个服务,每个服务一般都会部署多个实例。如果每个服务都要手动启停,那么效率之低、维护量之大可想而知。这时候就需要一个工具能够管理一组相关联的的应用容器,这就是Docker Compose。
下载最新docker-compose地址
拖至root文件夹下,执行一下文件
# 修改名称
mv docker-compose-linux-x86_64 docker-compose
#复制到 /usr/local/bin/
cp -r docker-compose /usr/local/bin
#切换到该目录下
cd /usr/local/bin
#添加权限
sudo chmod +x /usr/local/bin/docker-compose
#查看docker-compose版本(出现版本号,表示安装成功)
docker-compose -v
Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全、标识和管理等,扩展了开源Docker Distribution。作为一个企业级私有Registry服务器,Harbor提供了更好的性能和安全。提升用户使用Registry构建和运行环境传输镜像的效率。Harbor支持安装在多个Registry节点的镜像资源复制,镜像全部保存在私有Registry中, 确保数据和知识产权在公司内部网络中管控。另外,Harbor也提供了高级的安全特性,诸如用户管理,访问控制和活动审计等,下面进行Harbor的安装实战。
# 解压到对应的文件夹下
tar -zxvf harbor-offline-installer-v2.8.3.tgz -C /usr/local
# 切换到该目录下
cd /usr/local/harbor
# 复制出来配置文件
cp harbor.yml.tmpl harbor.yml
# 修改端口号;修改端口,不要重复;注释https内容
vi harbor.yml
# 在该目录执行启动命令
./install.sh
# harbor启动成功,打印日内容下。(执行命令后,要稍微等一会才会出现下面的日志)
[root@k8s-node harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 20.10.20
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 2.20.2
[Step 2]: loading Harbor images ...
0c3d3de3a100: Loading layer 38.43MB/38.43MB
176a9faee2d2: Loading layer 6.176MB/6.176MB
7533b07674a0: Loading layer 4.096kB/4.096kB
9ab27df52911: Loading layer 3.072kB/3.072kB
457b8a810324: Loading layer 17.57MB/17.57MB
8ade677a8a4b: Loading layer 18.36MB/18.36MB
Loaded image: goharbor/registry-photon:v2.8.3
ae6af9dcdf7c: Loading layer 6.171MB/6.171MB
d9b2d282124e: Loading layer 9.098MB/9.098MB
71d01ecf12a5: Loading layer 15.88MB/15.88MB
a93bf4c4de26: Loading layer 29.29MB/29.29MB
d6ccdcf712be: Loading layer 22.02kB/22.02kB
20d0340657f4: Loading layer 15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.8.3
7076e9de5fb2: Loading layer 6.171MB/6.171MB
06edddd4eeea: Loading layer 9.098MB/9.098MB
4c8df5f33db0: Loading layer 14.47MB/14.47MB
7bf292abe752: Loading layer 29.29MB/29.29MB
ac4de38627ae: Loading layer 22.02kB/22.02kB
687c00954816: Loading layer 14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.8.3
ab5bc430313c: Loading layer 90.16MB/90.16MB
dc3ba398e48c: Loading layer 3.584kB/3.584kB
d26b379ad813: Loading layer 3.072kB/3.072kB
93e3e2322706: Loading layer 2.56kB/2.56kB
0bf9c54793f1: Loading layer 3.072kB/3.072kB
2742f8f52b00: Loading layer 3.584kB/3.584kB
299dda8831bd: Loading layer 20.48kB/20.48kB
Loaded image: goharbor/harbor-log:v2.8.3
02ddc8ed9baf: Loading layer 85.6MB/85.6MB
377838d34c47: Loading layer 3.072kB/3.072kB
1bda8bcd6461: Loading layer 59.9kB/59.9kB
90ea325b2c6d: Loading layer 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.8.3
3996ab5000eb: Loading layer 9.188MB/9.188MB
03553e550818: Loading layer 3.584kB/3.584kB
9f2717a623b0: Loading layer 2.56kB/2.56kB
ce715e5a53cf: Loading layer 47.46MB/47.46MB
9505353423e5: Loading layer 48.25MB/48.25MB
Loaded image: goharbor/harbor-jobservice:v2.8.3
a558d1ee4c57: Loading layer 72.76MB/72.76MB
737b36f453c0: Loading layer 38.63MB/38.63MB
62e5d1841e72: Loading layer 19.93MB/19.93MB
0892d5f92493: Loading layer 65.54kB/65.54kB
9c6cbb44da28: Loading layer 2.56kB/2.56kB
29bb9597a5c7: Loading layer 1.536kB/1.536kB
a4a95076ba9e: Loading layer 12.29kB/12.29kB
17f763aeb83a: Loading layer 2.123MB/2.123MB
69aecf98c0b8: Loading layer 416.8kB/416.8kB
Loaded image: goharbor/prepare:v2.8.3
b99dc282b3c7: Loading layer 9.188MB/9.188MB
786372442d5c: Loading layer 3.584kB/3.584kB
c95eff9c3c92: Loading layer 2.56kB/2.56kB
69a6620f70fd: Loading layer 59.22MB/59.22MB
faee135ed65a: Loading layer 5.632kB/5.632kB
b8228ebe38a4: Loading layer 116.7kB/116.7kB
e2db669e8a7c: Loading layer 44.03kB/44.03kB
1d973fccb394: Loading layer 60.17MB/60.17MB
747dd0c43ef1: Loading layer 2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.8.3
1122996461e4: Loading layer 6.176MB/6.176MB
c11d210da0c1: Loading layer 4.096kB/4.096kB
7abff3111e9b: Loading layer 17.57MB/17.57MB
569fe4e2f2c9: Loading layer 3.072kB/3.072kB
bca259d7c630: Loading layer 31.01MB/31.01MB
2dda2be83cfd: Loading layer 49.37MB/49.37MB
Loaded image: goharbor/harbor-registryctl:v2.8.3
825a82984415: Loading layer 82.12MB/82.12MB
Loaded image: goharbor/nginx-photon:v2.8.3
39074d649f8c: Loading layer 6.707MB/6.707MB
688b64470d74: Loading layer 4.096kB/4.096kB
320f85b1e3eb: Loading layer 3.072kB/3.072kB
dde1dfb74607: Loading layer 194.8MB/194.8MB
229337a9e8cc: Loading layer 14.1MB/14.1MB
8c74af69019d: Loading layer 209.7MB/209.7MB
Loaded image: goharbor/trivy-adapter-photon:v2.8.3
74b07281d2e5: Loading layer 82.12MB/82.12MB
751e146c3c0f: Loading layer 6.1MB/6.1MB
2cbfa90aca6d: Loading layer 1.233MB/1.233MB
Loaded image: goharbor/harbor-portal:v2.8.3
3a8f210ea3e0: Loading layer 116.2MB/116.2MB
06434a1eae73: Loading layer 25.18MB/25.18MB
0923361e26b9: Loading layer 5.12kB/5.12kB
e4658596b9ef: Loading layer 6.144kB/6.144kB
350bc2e11862: Loading layer 3.072kB/3.072kB
54847be3f348: Loading layer 2.048kB/2.048kB
67296b765de0: Loading layer 2.56kB/2.56kB
136c1f931ee8: Loading layer 2.56kB/2.56kB
c44a36e8102e: Loading layer 2.56kB/2.56kB
60bcea6b0ccb: Loading layer 9.728kB/9.728kB
Loaded image: goharbor/harbor-db:v2.8.3
85c2b8de0e50: Loading layer 9.188MB/9.188MB
1fd29ea96459: Loading layer 26.04MB/26.04MB
9154b665386d: Loading layer 4.608kB/4.608kB
9e173c1e037d: Loading layer 26.83MB/26.83MB
Loaded image: goharbor/harbor-exporter:v2.8.3
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
WARNING:root:WARNING: HTTP protocol is insecure. Harbor will deprecate http protocol in the future. Please make sure to upgrade to https
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir
Note: stopping existing Harbor instance ...
[Step 5]: starting Harbor ...
[+] Running 10/10
✔ Network harbor_harbor Created 0.1s
✔ Container harbor-log Started 1.3s
✔ Container harbor-portal Started 2.9s
✔ Container redis Started 2.8s
✔ Container registryctl Started 2.7s
✔ Container registry Started 3.1s
✔ Container harbor-db Started 2.9s
✔ Container harbor-core Started 3.7s
✔ Container harbor-jobservice Started 4.9s
✔ Container nginx Started 4.9s
✔ ----Harbor has been installed and started successfully.----