在这里插入图片描述

安装docker-compose

root@zhizhuxia:~# apt  install docker-compose  # 安装 docker-compose

root@zhizhuxia:~#  docker-compose --version # 查看 docker-compose 版本
docker-compose version 1.29.2, build unknown

安装 harbor

harbor 版本

下载

root@zhizhuxia:/home/david/workspaces# mkdir harbor # 创建 harbor 目录
root@zhizhuxia:/home/david/workspaces# cd harbor/ # 进入目录
root@zhizhuxia:/home/david/workspaces/harbor# wget https://github.com/goharbor/harbor/releases/download/v2.6.1/harbor-offline-installer-v2.6.1.tgz # 下载最新离线版本

解压

root@zhizhuxia:/home/david/workspaces/harbor# tar zxf harbor-offline-installer-v2.6.1.tgz  # 解压
root@zhizhuxia:/home/david/workspaces/harbor# ll
总用量 739548
drwxr-xr-x 3 root root      4096 1020 14:30 ./
drwxr-xr-x 4 root root      4096 1020 14:27 ../
drwxr-xr-x 2 root root      4096 1020 14:30 harbor/
-rw-r--r-- 1 root root 757278514 1011 10:09 harbor-offline-installer-v2.6.1.tgz
root@zhizhuxia:/home/david/workspaces/harbor# cd harbor/ # 进入harbor目录
root@zhizhuxia:/home/david/workspaces/harbor/harbor# ll
总用量 743388
drwxr-xr-x 2 root root      4096 1020 14:30 ./
drwxr-xr-x 3 root root      4096 1020 14:30 ../
-rw-r--r-- 1 root root      3639 1010 11:32 common.sh
-rw-r--r-- 1 root root 761180661 1010 11:33 harbor.v2.6.1.tar.gz
-rw-r--r-- 1 root root     10491 1010 11:32 harbor.yml.tmpl
-rwxr-xr-x 1 root root      3171 1010 11:32 install.sh*
-rw-r--r-- 1 root root     11347 1010 11:32 LICENSE
-rwxr-xr-x 1 root root      1881 1010 11:32 prepare*

配置 harbor.yml

root@zhizhuxia:/home/david/workspaces/harbor/harbor# cp harbor.yml.tmpl harbor.yml # 拷贝 harbor.yml 模板
root@zhizhuxia:/home/david/workspaces/harbor/harbor# vim harbor.yml # 编辑 harbor.yml 文件

修改这些内容
在这里插入图片描述
这里使用腾讯云的免费证书
在这里插入图片描述

在这里插入图片描述

运行./prepare

每次修改完配置文件后都需要运行

root@zhizhuxia:/home/david/workspaces/harbor/harbor# ./prepare 
prepare base dir is set to /home/david/workspaces/harbor/harbor
Unable to find image 'goharbor/prepare:v2.6.1' locally
v2.6.1: Pulling from goharbor/prepare
e82db3878067: Pull complete 
4eb87f61c01b: Pull complete 
38d5f9d1f8bb: Pull complete 
ce463d8bd4fd: Pull complete 
3ff5c5228716: Pull complete 
81b6713e3f24: Pull complete 
0764ab8b6c6c: Pull complete 
288d8b2c0c34: Pull complete 
9edcfb579c8b: Pull complete 
7ff00c916846: Pull complete 
Digest: sha256:7046ed9124b729a5e49c1833812cfc06dc682bae9a53c92d4898911cb74dde77
Status: Downloaded newer image for goharbor/prepare:v2.6.1
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

安装

root@zhizhuxia:/home/david/workspaces/harbor/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 v2.6.0

[Step 2]: loading Harbor images ...
b1c55ad746b8: Loading layer [==================================================>]  5.754MB/5.754MB
3fad059e5b96: Loading layer [==================================================>]  8.718MB/8.718MB
ac3d56834181: Loading layer [==================================================>]  15.88MB/15.88MB
ac64291e7095: Loading layer [==================================================>]  29.29MB/29.29MB
347c69d047c1: Loading layer [==================================================>]  22.02kB/22.02kB
2bc68bdd74b4: Loading layer [==================================================>]  15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.6.1
a3f881ff8a8a: Loading layer [==================================================>]  5.759MB/5.759MB
bf4fe2665116: Loading layer [==================================================>]  90.88MB/90.88MB
1bbf13d3b736: Loading layer [==================================================>]  3.072kB/3.072kB
6864945044da: Loading layer [==================================================>]  4.096kB/4.096kB
e74206fce300: Loading layer [==================================================>]  91.67MB/91.67MB
Loaded image: goharbor/chartmuseum-photon:v2.6.1
d1cca5e33760: Loading layer [==================================================>]  126.9MB/126.9MB
f21ade3affb4: Loading layer [==================================================>]  3.584kB/3.584kB
2b10bb22d396: Loading layer [==================================================>]  3.072kB/3.072kB
cddb26029f4f: Loading layer [==================================================>]   2.56kB/2.56kB
120e581fca06: Loading layer [==================================================>]  3.072kB/3.072kB
b55ab4161be8: Loading layer [==================================================>]  3.584kB/3.584kB
708b88dc9728: Loading layer [==================================================>]  20.99kB/20.99kB
Loaded image: goharbor/harbor-log:v2.6.1
aa3c0eeab3fd: Loading layer [==================================================>]  5.759MB/5.759MB
08acd59679e5: Loading layer [==================================================>]  4.096kB/4.096kB
dbfa72b62e7c: Loading layer [==================================================>]   17.1MB/17.1MB
3db46c922bff: Loading layer [==================================================>]  3.072kB/3.072kB
db46f9ab20a1: Loading layer [==================================================>]  29.15MB/29.15MB
c28b264c5c77: Loading layer [==================================================>]  47.04MB/47.04MB
Loaded image: goharbor/harbor-registryctl:v2.6.1
46e1d8c22785: Loading layer [==================================================>]  119.1MB/119.1MB
Loaded image: goharbor/nginx-photon:v2.6.1
ebe1f7ed9475: Loading layer [==================================================>]  7.162MB/7.162MB
780db4ad3bef: Loading layer [==================================================>]  4.096kB/4.096kB
dc07146a4e90: Loading layer [==================================================>]  3.072kB/3.072kB
2cdc8f8be3a6: Loading layer [==================================================>]  91.21MB/91.21MB
d4efae655490: Loading layer [==================================================>]  12.86MB/12.86MB
c11badbab4ee: Loading layer [==================================================>]  104.9MB/104.9MB
Loaded image: goharbor/trivy-adapter-photon:v2.6.1
Loaded image: goharbor/prepare:v2.6.1
59c6fef03969: Loading layer [==================================================>]  1.097MB/1.097MB
0b0d97fd8a80: Loading layer [==================================================>]  5.888MB/5.888MB
6f21e17052fb: Loading layer [==================================================>]    169MB/169MB
480717132aea: Loading layer [==================================================>]  16.96MB/16.96MB
817dc53a51cf: Loading layer [==================================================>]  4.096kB/4.096kB
beeda54c09df: Loading layer [==================================================>]  6.144kB/6.144kB
0de0c418dfa2: Loading layer [==================================================>]  3.072kB/3.072kB
394a42c14a01: Loading layer [==================================================>]  2.048kB/2.048kB
c53687716453: Loading layer [==================================================>]   2.56kB/2.56kB
46e9e5d728c4: Loading layer [==================================================>]   2.56kB/2.56kB
e05b0e58bb47: Loading layer [==================================================>]   2.56kB/2.56kB
85d4f51c325c: Loading layer [==================================================>]  8.704kB/8.704kB
Loaded image: goharbor/harbor-db:v2.6.1
0bfa75b1d074: Loading layer [==================================================>]  8.902MB/8.902MB
0dda41e1e1a6: Loading layer [==================================================>]  3.584kB/3.584kB
13be21b41d86: Loading layer [==================================================>]   2.56kB/2.56kB
f92838d6a967: Loading layer [==================================================>]  97.91MB/97.91MB
e97573477193: Loading layer [==================================================>]   98.7MB/98.7MB
Loaded image: goharbor/harbor-jobservice:v2.6.1
15fecb8d6c42: Loading layer [==================================================>]  119.1MB/119.1MB
098f54fce48f: Loading layer [==================================================>]  7.535MB/7.535MB
3dc6ef297f52: Loading layer [==================================================>]  1.185MB/1.185MB
Loaded image: goharbor/harbor-portal:v2.6.1
775b1ccf1721: Loading layer [==================================================>]  5.754MB/5.754MB
f4ef31b9659f: Loading layer [==================================================>]  8.718MB/8.718MB
7c9e733a4621: Loading layer [==================================================>]  14.47MB/14.47MB
148050e3b89d: Loading layer [==================================================>]  29.29MB/29.29MB
500fdc71742e: Loading layer [==================================================>]  22.02kB/22.02kB
d38ecdf0c794: Loading layer [==================================================>]  14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.6.1
0b6707dd33bc: Loading layer [==================================================>]  5.759MB/5.759MB
8107a2426b6d: Loading layer [==================================================>]  4.096kB/4.096kB
130b71e83c08: Loading layer [==================================================>]  3.072kB/3.072kB
3daa3b45e084: Loading layer [==================================================>]   17.1MB/17.1MB
e1f022373798: Loading layer [==================================================>]   17.9MB/17.9MB
Loaded image: goharbor/registry-photon:v2.6.1
b8ab82a27cb4: Loading layer [==================================================>]  8.902MB/8.902MB
031794af342e: Loading layer [==================================================>]  3.584kB/3.584kB
a6c93180465a: Loading layer [==================================================>]   2.56kB/2.56kB
1181f6dc3b6f: Loading layer [==================================================>]  80.74MB/80.74MB
6aea11036399: Loading layer [==================================================>]  5.632kB/5.632kB
84ea4b6c2a1f: Loading layer [==================================================>]  105.5kB/105.5kB
9da21a8aaea8: Loading layer [==================================================>]  44.03kB/44.03kB
3a6281e6c8dc: Loading layer [==================================================>]  81.68MB/81.68MB
57ba35dc2c40: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.6.1
24243fc0136d: Loading layer [==================================================>]  8.902MB/8.902MB
9778bfbfaf4b: Loading layer [==================================================>]  24.64MB/24.64MB
c904704d3e3f: Loading layer [==================================================>]  4.608kB/4.608kB
0ee8cf6901bd: Loading layer [==================================================>]  25.43MB/25.43MB
Loaded image: goharbor/harbor-exporter:v2.6.1
5e3e5b804996: Loading layer [==================================================>]  119.9MB/119.9MB
c7323c3b23ff: Loading layer [==================================================>]  3.072kB/3.072kB
6ab347b42178: Loading layer [==================================================>]   59.9kB/59.9kB
4587d0666b27: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.6.1


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /home/david/workspaces/harbor/harbor
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/jobservice/config.yml
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/nginx/nginx.conf
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
loaded secret from file: /data/secret/keys/secretkey
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir


Note: stopping existing Harbor instance ...
Warning: No resource found to remove for project "harbor".


[Step 5]: starting Harbor ...
[+] Running 10/10
 ⠿ Network harbor_harbor        Created                                                                                                 0.0s
 ⠿ Container harbor-log         Started                                                                                                 0.4s
 ⠿ Container harbor-portal      Started                                                                                                 0.8s
 ⠿ Container redis              Started                                                                                                 1.2s
 ⠿ Container registry           Started                                                                                                 1.2s
 ⠿ Container harbor-db          Started                                                                                                 1.1s
 ⠿ Container registryctl        Started                                                                                                 1.2s
 ⠿ Container harbor-core        Started                                                                                                 1.6s
 ⠿ Container nginx              Started                                                                                                 2.0s
 ⠿ Container harbor-jobservice  Started                                                                                                 2.0s
✔ ----Harbor has been installed and started successfully.----

查看安装结果

root@zhizhuxia:/home/david/workspaces/harbor/harbor# docker ps
CONTAINER ID   IMAGE                                COMMAND                  CREATED         STATUS                            PORTS                                                                                                                           NAMES
9ea81c6ebebb   goharbor/harbor-jobservice:v2.6.1    "/harbor/entrypoint.…"   8 seconds ago   Up 2 seconds (health: starting)                                                                                                                                   harbor-jobservice
a77112caebd0   goharbor/nginx-photon:v2.6.1         "nginx -g 'daemon of…"   8 seconds ago   Up 6 seconds (health: starting)   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:8443->8443/tcp, :::8443->8443/tcp                                            nginx
bb95ea1e2ce1   goharbor/harbor-core:v2.6.1          "/harbor/entrypoint.…"   8 seconds ago   Up 6 seconds (health: starting)                                                                                                                                   harbor-core
b2470e489fa9   goharbor/harbor-registryctl:v2.6.1   "/home/harbor/start.…"   8 seconds ago   Up 7 seconds (health: starting)                                                                                                                                   registryctl
cf17760355e7   goharbor/harbor-portal:v2.6.1        "nginx -g 'daemon of…"   8 seconds ago   Up 7 seconds (health: starting)                                                                                                                                   harbor-portal
24e151df4775   goharbor/redis-photon:v2.6.1         "redis-server /etc/r…"   8 seconds ago   Up 7 seconds (health: starting)                                                                                                                                   redis
3466b07ce574   goharbor/registry-photon:v2.6.1      "/home/harbor/entryp…"   8 seconds ago   Up 7 seconds (health: starting)                                                                                                                                   registry
f771b227bcaf   goharbor/harbor-db:v2.6.1            "/docker-entrypoint.…"   8 seconds ago   Up 7 seconds (health: starting)                                                                                                                                   harbor-db
6e4544c00b51   goharbor/harbor-log:v2.6.1           "/bin/sh -c /usr/loc…"   8 seconds ago   Up 7 seconds (health: starting)   127.0.0.1:1514->10514/tcp

使用

常用管理命令

停止服务: docker-compose stop
开始服务: docker-compose start
重启服务: docker-compose restart
停止服务并删除容器: docker-compose down -v
启动服务并运行容器: docker-compose up -d

注意:这些命令均要在harbor目录下运行

使用浏览器登录
在这里插入图片描述

创建项目
在这里插入图片描述

Docker使用

修改Docker配置,/etc/docker/daemon.json 添加 harbor 服务

vim /etc/docker/daemon.json

{
  "insecure-registries" : ["harbor域名地址:端口号"]
}

然后重启docker

systemctl daemon-reload 
systemctl restart docker
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐