本文主要是介绍史上最全的整合Harbor安装教程,哈哈哈哈,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、安装docker
下载地址:https://download.docker.com/linux/static/stable/x86_64/docker-23.0.4.tgz
1.1 解压二进制包
wget https://download.docker.com/linux/static/stable/x86_64/docker-23.0.4.tgz
tar zxvf docker-23.0.4.tgz
mv docker/* /usr/bin
1.2 systemd管理docker
cat > /usr/lib/systemd/system/docker.service << EOF
[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 -H --insecure-registry 192.168.8.111
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
1.3 创建配置文件
mkdir /etc/docker
cat > /etc/docker/daemon.json <<'EOF'
{"registry-mirrors": ["https://jkfdsf2u.mirror.aliyuncs.com","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://dockerhub.azk8s.cn","http://hub-mirror.c.163.com"],"insecure-registries":["core.harbor.domain:32388"],"max-concurrent-downloads": 10,"max-concurrent-uploads": 5,"log-driver": "json-file","log-opts": {"max-size": "300m","max-file": "2"},"live-restore": true
}
EOF# docker优化
# registry-mirrors 自定义的镜像地址
# 修改docker Cgroup Driver 为systemtd启动管理,是k8s需要,默认是cgroupfs
# max-concurrent-downloads: 最大并发下载
# max-concurrent-uploads: 最大并发上传
# log-driver: 日志格式化为 JSON。这是 Docker 默认的日志驱动程序。
# log-opts: 日志设置,单文件最大,最大几个文件
# 容器的日志都在 /var/lib/docker/containers/容器名/xxx.log
# live-restore: 在docker守护进程不可用时使容器保持活动状态
registry-mirrors: 阿里云镜像加速器
insecure-registries: 本机ip地址,不加docker login时会拒绝连接
1.4 启动并设置开机启动
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
systemctl status docker
二、docker-compose安装
Docker Compose 是用来做Docker 的多容器控制,有了 Docker Compose 你可以把所有繁复的 Docker 操作全都一条命令,自动化的完成。
官网地址:https://docs.docker.com/compose/install/linux/
下载与安装:
-
在安装docker时候已经完成了安装,直接查看版本号,查看是否安装成功
# 安装步骤 略 ....
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin# 查看docker compose的版本
docker compose version
-
或者单独安装
# 创建指定目录存储docker compose
mkdir -p /usr/local/lib/docker/cli-plugins# 下载并移动
curl -SL https://github.com/docker/compose/releases/download/v2.14.2/docker-compose-linux-x86_64 -o /usr/local/lib/docker/cli-plugins/docker-compose# 给docker-compose文件赋予可执行权限
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose# 查看docker compose的版本
docker compose version
入门案例
需求:使用docker compose部署redis
-
docker-compose.yml文件的内容如下所示:
services:redis:image: redis:7.0.10container_name: redis02ports:- "6389:6379"volumes:- redis-data:/data
volumes:redis-data: {}
docker compose相关命令:
# 启动容器(如果不存在容器就创建、存在则修改)
docker compose -f docker-compose.yml up -d# 删除所有容器
docker compose -f docker-compose.yml down# 停止所有容器
docker compose -f docker-compose.yml stop# 启动所有容器
docker compose -f docker-compose.yml start# 重启所有容器
docker compose -f docker-compose.yml restart
docker compose文件中其他的常见指令参考官方文档:https://docs.docker.com/compose/compose-file/05-services/
-
多容器配置文件示例:
services:mysql:container_name: mysql02image: mysql:8.0.30ports:- "3307:3306"volumes:- mysql_data:/var/lib/mysql- mysql_conf:/etc/mysqlprivileged: trueenvironment:- "MYSQL_ROOT_PASSWORD=1234"redis:image: redis:7.0.10container_name: redis02ports:- "6389:6379"volumes:- redis-data:/data
volumes:mysql_data: {}mysql_conf: {}redis-data: {}
三、Harbor安装
下载地址:
https://github.com/goharbor/harbor/releases
3.1 生成证书(可以不配置)
1.添加hosts
wget https://github.com/goharbor/harbor/releases/download/v2.8.0/harbor-offline-installer-v2.8.0.tgz
echo "192.168.8.111 core.harbor.domain" >> /etc/hosts
cat /etc/hosts
2.生成证书
#!/bin/bash# 生成证书的路径
mkdir -p /data/cert
cd /data/certopenssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=harbor19" -key ca.key -out ca.crt
openssl genrsa -out core.harbor.domain.key 4096
openssl req -sha512 -new -subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=harbor19" -key core.harbor.domain.key -out core.harbor.domain.csrcat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=harbor19
DNS.2=harbor
DNS.3=ks-allinone
EOFopenssl x509 -req -sha512 -days 3650 -extfile v3.ext -CA ca.crt -CAkey ca.key -CAcreateserial -in core.harbor.domain.csr -out core.harbor.domain.crtopenssl x509 -inform PEM -in core.harbor.domain.crt -out core.harbor.domain.certcp core.harbor.domain.crt /etc/pki/ca-trust/source/anchors/core.harbor.domain.crt
update-ca-trust
查看生成文件
[root@host cert]# ls /data/cert/
ca.crt ca.key ca.srl core.harbor.domain.cert core.harbor.domain.crt core.harbor.domain.csr core.harbor.domain.key v3.ext
3.把这三个复制到docke下
mkdir -p /etc/docker/certs.d/core.harbor.domain/
cp /data/cert/core.harbor.domain.cert /etc/docker/certs.d/core.harbor.domain/
cp /data/cert/core.harbor.domain.key /etc/docker/certs.d/core.harbor.domain/
cp /data/cert/ca.crt /etc/docker/certs.d/core.harbor.domain/
3.2 安装
1.解压
[root@localhost ~]# tar -zxvf harbor-offline-installer-v2.8.0.tgz -C /usr/local/
harbor/harbor.v2.8.0.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl
2.修改配置
[root@localhost ~]# cd /usr/local/harbor/
[root@localhost /usr/local/harbor]# ls /usr/local/harbor/
common.sh harbor.yml.tmpl LICENSE
harbor.v2.8.0.tar.gz install.sh prepare
[root@localhost /usr/local/harbor]# cp harbor.yml.tmpl harbor.yml //配置模板信息
[root@localhost /usr/local/harbor]# cat harbor.yml.tmpl | grep -v '#' | grep -v '^$' > harbor.yml
[root@localhost /usr/local/harbor]# vim harbor.yml
hostname: core.harbor.domain //修改为当前的主机ip
http:port: 32388 //修改为当前的主机端口
# https related config //https通讯协议,不考虑对外进行关闭
# https:# https port for harbor, default is 443
# port: 443# The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/pathharbor_admin_password: Harbor12345 //默认密码
database:password: root123max_idle_conns: 100max_open_conns: 900conn_max_lifetime: 5mconn_max_idle_time: 0
data_volume: /data //数据库存放路径
trivy:ignore_unfixed: falseskip_update: falseoffline_scan: falsesecurity_check: vulninsecure: false
jobservice:max_job_workers: 10
notification:webhook_job_max_retry: 3
log: //日志容器level: info //为最低级别的日志local:rotate_count: 50 //最多滚动50个日志rotate_size: 200M //每次滚动超过200M后将重新生成location: /var/log/harbor //日志的存放目录
_version: 2.8.0
proxy:http_proxy:https_proxy:no_proxy:components:- core- jobservice- trivy
upload_purging:enabled: trueage: 168hinterval: 24hdryrun: false
cache:enabled: falseexpire_hours: 24
3. 安装
注意:如果安装的时候报错了,可以给docker配置多个镜像地址:
// 编辑文件
vim /etc/docker/daemon.json// 文件内容
{"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","http://f1361db2.m.daocloud.io","https://mirror.ccs.tencentyun.com","https://phtv51hj.mirror.aliyuncs.com"]
}
启动关闭命令
docker compose -f docker-compose.yml up -d 启动 Harbor
docker compose -f docker-compose.yml stop 关闭 Harbor
安装一切顺利的话,Harbor has been installed and started successfully.如图:
会遇到的几个问题如下:
上文已经把harbor下载好,接下来需要修改配置文件,我便自己填写了一个yml的配置文件,发现报错了,如下:报错一
## 注意此步是自己编写的yml文件,但是会出现下面的报错信息,提示data_volume找不到
[root@linux-001 harbor]# cat harbor.yml
hostname: harbor.ideacome.com
certificate: /opt/harbor/ideacome.crt
private_key: /opt/harbor/ideacome.key
harbor_admin_password: harbor-12345[root@linux-003 harbor]# sh install.sh[Step 0]: checking if docker is installed ...Note: docker version: 20.10.4[Step 1]: checking docker-compose is installed ...Note: docker-compose version: 1.28.5[Step 2]: loading Harbor images ...
07ed3fe22282: Loading layer [==================================================>] 34.51MB/34.51MB
632651017131: Loading layer [==================================================>] 8.071MB/8.071MB
cff019bd8e54: Loading layer [==================================================>] 3.584kB/3.584kB
db8113c9a129: Loading layer [==================================================>] 2.56kB/2.56kB
04eaffb344c9: Loading layer [==================================================>] 61.03MB/61.03MB
30932a235d0d: Loading layer [==================================================>] 61.85MB/61.85MB
Loaded image: goharbor/harbor-jobservice:v2.2.0
68170e81b04b: Loading layer [==================================================>] 34.51MB/34.51MB
c0276ff1011e: Loading layer [==================================================>] 7.815MB/7.815MB
892518eb7e09: Loading layer [==================================================>] 17.61MB/17.61MB
25f373af3c04: Loading layer [==================================================>] 4.608kB/4.608kB
df5c0f8011ee: Loading layer [==================================================>] 18.43MB/18.43MB
Loaded image: goharbor/harbor-exporter:v2.2.0
d6b0c623c73b: Loading layer [==================================================>] 4.933MB/4.933MB
494ceea2a6b4: Loading layer [==================================================>] 4.096kB/4.096kB
64e95a63b7a3: Loading layer [==================================================>] 3.072kB/3.072kB
f2c35b3b0dcd: Loading layer [==================================================>] 18.99MB/18.99MB
5c74d99fc846: Loading layer [==================================================>] 19.81MB/19.81MB
Loaded image: goharbor/registry-photon:v2.2.0
3fbc0344880d: Loading layer [==================================================>] 8.072MB/8.072MB
9c5adc52de0d: Loading layer [==================================================>] 3.584kB/3.584kB
05781011aa08: Loading layer [==================================================>] 2.56kB/2.56kB
19e4b43530bc: Loading layer [==================================================>] 53.27MB/53.27MB
9a88bba5ca8d: Loading layer [==================================================>] 5.632kB/5.632kB
7c2bf6707239: Loading layer [==================================================>] 87.55kB/87.55kB
b1aeff496e1d: Loading layer [==================================================>] 11.78kB/11.78kB
f8d3079c10d4: Loading layer [==================================================>] 54.2MB/54.2MB
eb473baf6abd: Loading layer [==================================================>] 2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.2.0
f649b07d9770: Loading layer [==================================================>] 63.77MB/63.77MB
a1252bd74521: Loading layer [==================================================>] 80MB/80MB
12a45cabca01: Loading layer [==================================================>] 6.144kB/6.144kB
cb64020cac49: Loading layer [==================================================>] 2.56kB/2.56kB
11273c337dac: Loading layer [==================================================>] 2.56kB/2.56kB
06bf2b44257c: Loading layer [==================================================>] 2.56kB/2.56kB
ae1d550e31f7: Loading layer [==================================================>] 2.56kB/2.56kB
5418b645d05a: Loading layer [==================================================>] 11.26kB/11.26kB
Loaded image: goharbor/harbor-db:v2.2.0
165bc38d4a20: Loading layer [==================================================>] 4.926MB/4.926MB
4450dd70e473: Loading layer [==================================================>] 5.926MB/5.926MB
571aff5ac473: Loading layer [==================================================>] 14.86MB/14.86MB
7213db5cd3f6: Loading layer [==================================================>] 27.36MB/27.36MB
feb90353404b: Loading layer [==================================================>] 22.02kB/22.02kB
2bf612d23dd5: Loading layer [==================================================>] 14.86MB/14.86MB
Loaded image: goharbor/notary-server-photon:v2.2.0
75b7bc9e1233: Loading layer [==================================================>] 6.237MB/6.237MB
45cc62077a3e: Loading layer [==================================================>] 4.096kB/4.096kB
0254af6d0275: Loading layer [==================================================>] 3.072kB/3.072kB
6b42f8a7f98d: Loading layer [==================================================>] 28.3MB/28.3MB
4c3750e9c704: Loading layer [==================================================>] 11.38MB/11.38MB
2f3db0c6619f: Loading layer [==================================================>] 40.5MB/40.5MB
Loaded image: goharbor/trivy-adapter-photon:v2.2.0
bbd0a1895331: Loading layer [==================================================>] 4.933MB/4.933MB
5db7b6078317: Loading layer [==================================================>] 4.096kB/4.096kB
b2a993735d1e: Loading layer [==================================================>] 18.99MB/18.99MB
46f8d3251467: Loading layer [==================================================>] 3.072kB/3.072kB
36435ed81d46: Loading layer [==================================================>] 25.32MB/25.32MB
586ede682f3f: Loading layer [==================================================>] 45.14MB/45.14MB
Loaded image: goharbor/harbor-registryctl:v2.2.0
59cead1174d4: Loading layer [==================================================>] 35.94MB/35.94MB
8c26e21f2027: Loading layer [==================================================>] 3.072kB/3.072kB
741a65c6dac7: Loading layer [==================================================>] 59.9kB/59.9kB
438633fad008: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.2.0
2fc5cd36d28c: Loading layer [==================================================>] 76.07MB/76.07MB
6a135eaee93d: Loading layer [==================================================>] 3.584kB/3.584kB
e5c3feb6aca0: Loading layer [==================================================>] 3.072kB/3.072kB
a31d1977777a: Loading layer [==================================================>] 2.56kB/2.56kB
0969721e9ff9: Loading layer [==================================================>] 3.072kB/3.072kB
e790c9ba4ed2: Loading layer [==================================================>] 3.584kB/3.584kB
ee43eb3a3893: Loading layer [==================================================>] 12.29kB/12.29kB
Loaded image: goharbor/harbor-log:v2.2.0
45a339152b94: Loading layer [==================================================>] 6.779MB/6.779MB
Loaded image: goharbor/nginx-photon:v2.2.0
e6c87254655c: Loading layer [==================================================>] 4.926MB/4.926MB
385174b02cde: Loading layer [==================================================>] 5.926MB/5.926MB
427415aeb0cc: Loading layer [==================================================>] 13.33MB/13.33MB
a46c9a86420a: Loading layer [==================================================>] 27.36MB/27.36MB
0646903e30c4: Loading layer [==================================================>] 22.02kB/22.02kB
74c332a73d82: Loading layer [==================================================>] 13.33MB/13.33MB
Loaded image: goharbor/notary-signer-photon:v2.2.0
d6c1f4fe3f89: Loading layer [==================================================>] 4.932MB/4.932MB
da140a6b9c66: Loading layer [==================================================>] 62.71MB/62.71MB
014c145ecf1c: Loading layer [==================================================>] 3.072kB/3.072kB
73ad0cb1c27d: Loading layer [==================================================>] 4.096kB/4.096kB
4d442ea85017: Loading layer [==================================================>] 63.53MB/63.53MB
Loaded image: goharbor/chartmuseum-photon:v2.2.0
c8fae5121874: Loading layer [==================================================>] 77.48MB/77.48MB
3b920f9fa989: Loading layer [==================================================>] 54.62MB/54.62MB
f156b6b2a217: Loading layer [==================================================>] 2.56kB/2.56kB
906ca23bc04b: Loading layer [==================================================>] 1.536kB/1.536kB
12b8ebf41897: Loading layer [==================================================>] 18.43kB/18.43kB
6190944c245c: Loading layer [==================================================>] 4.058MB/4.058MB
e08cb3f4e745: Loading layer [==================================================>] 278.5kB/278.5kB
Loaded image: goharbor/prepare:v2.2.0
366e44984cdc: Loading layer [==================================================>] 6.779MB/6.779MB
eb1850e4d6ec: Loading layer [==================================================>] 9.096MB/9.096MB
ecaa0fbfe5ea: Loading layer [==================================================>] 1.691MB/1.691MB
Loaded image: goharbor/harbor-portal:v2.2.0[Step 3]: preparing environment ...[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
Traceback (most recent call last):File "main.py", line 15, in <module>cli()File "/usr/lib/python3.6/site-packages/click/core.py", line 829, in __call__return self.main(*args, **kwargs)File "/usr/lib/python3.6/site-packages/click/core.py", line 782, in mainrv = self.invoke(ctx)File "/usr/lib/python3.6/site-packages/click/core.py", line 1259, in invokereturn _process_result(sub_ctx.command.invoke(sub_ctx))File "/usr/lib/python3.6/site-packages/click/core.py", line 1066, in invokereturn ctx.invoke(self.callback, **ctx.params)File "/usr/lib/python3.6/site-packages/click/core.py", line 610, in invokereturn callback(*args, **kwargs)File "/usr/src/app/commands/prepare.py", line 37, in prepareconfig_dict = parse_yaml_config(conf, with_notary=with_notary, with_trivy=with_trivy, with_chartmuseum=with_chartmuseum)File "/usr/src/app/utils/configs.py", line 168, in parse_yaml_configconfig_dict['data_volume'] = configs['data_volume']
KeyError: 'data_volume'
发现上文的报错后,发现harbor本身给提供了一个配置文件harbor.yml.tmpl,我们只需要修改此配置文件即可。
[root@linux-001 harbor]# mv harbor.yml harbor.yml.zdybak
[root@linux-001 harbor]#
[root@linux-001 harbor]# vim harbor.yml.tmpl
[root@linux-001 harbor]# cp harbor.yml.tmpl harbor.yml
[root@linux-001 harbor]# mkdir -p /data/harbor/[root@linux-001 harbor]# sh install.sh[Step 0]: checking if docker is installed ...Note: docker version: 20.10.4[Step 1]: checking docker-compose is installed ...Note: docker-compose version: 1.28.5[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-jobservice:v2.2.0
Loaded image: goharbor/harbor-exporter:v2.2.0
Loaded image: goharbor/registry-photon:v2.2.0
Loaded image: goharbor/harbor-core:v2.2.0
Loaded image: goharbor/harbor-db:v2.2.0
Loaded image: goharbor/notary-server-photon:v2.2.0
Loaded image: goharbor/trivy-adapter-photon:v2.2.0
Loaded image: goharbor/harbor-registryctl:v2.2.0
Loaded image: goharbor/redis-photon:v2.2.0
Loaded image: goharbor/harbor-log:v2.2.0
Loaded image: goharbor/nginx-photon:v2.2.0
Loaded image: goharbor/notary-signer-photon:v2.2.0
Loaded image: goharbor/chartmuseum-photon:v2.2.0
Loaded image: goharbor/prepare:v2.2.0
Loaded image: goharbor/harbor-portal:v2.2.0[Step 3]: preparing environment ...[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
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[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating redis ... done
Creating harbor-db ... done
Creating registry ... done
Creating harbor-portal ... done
Creating registryctl ... done
Creating harbor-core ... done
Creating nginx ... done
Creating harbor-jobservice ... done
? ----Harbor has been installed and started successfully.----
报错二:如下图 redis已经存在并运行
[root@localhost harbor]# sh install.sh[Step 0]: checking if docker is installed ...Note: docker version: 26.1.4[Step 1]: checking docker-compose is installed ...Note: Docker Compose version v2.27.1[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-core:v2.11.0
Loaded image: goharbor/harbor-db:v2.11.0
Loaded image: goharbor/nginx-photon:v2.11.0
Loaded image: goharbor/trivy-adapter-photon:v2.11.0
Loaded image: goharbor/redis-photon:v2.11.0
Loaded image: goharbor/registry-photon:v2.11.0
Loaded image: goharbor/prepare:v2.11.0
Loaded image: goharbor/harbor-portal:v2.11.0
Loaded image: goharbor/harbor-log:v2.11.0
Loaded image: goharbor/harbor-jobservice:v2.11.0
Loaded image: goharbor/harbor-registryctl:v2.11.0
Loaded image: goharbor/harbor-exporter:v2.11.0[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 dirNote: stopping existing Harbor instance ...
WARN[0000] /usr/local/harbor/docker-compose.yml: `version` is obsolete [Step 5]: starting Harbor ...
WARN[0000] /usr/local/harbor/docker-compose.yml: `version` is obsolete
[+] Running 2/2✔ Network harbor_harbor Created 0.1s ✔ Container harbor-log Created 0.1s ⠋ Container harbor-db Creating 0.0s ⠋ Container redis Creating 0.0s ⠋ Container registry Creating 0.0s ⠋ Container registryctl Creating 0.0s ⠋ Container harbor-portal Creating 0.0s
Error response from daemon: Conflict. The container name "/redis" is already in use by container "7c087c034657b695b2b42b7337e6f06dcf5731613f86a57472b44884358fdab2". You have to remove (or rename) that container to be able to reuse that name.
解决如下:
[root@localhost harbor]# docker rm -f redis
redis
[root@localhost harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a474c18c5463 minio/minio "/usr/bin/docker-ent…" 4 weeks ago Up 2 hours 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp, 0.0.0.0:9001->9000/tcp, :::9001->9000/tcp minio
91360e222bc7 mysql:8.0.30 "docker-entrypoint.s…" 8 weeks ago Up 2 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
把redis删掉,从新运行即可成功:
[root@localhost harbor]# sh install.sh[Step 0]: checking if docker is installed ...Note: docker version: 26.1.4[Step 1]: checking docker-compose is installed ...Note: Docker Compose version v2.27.1[Step 2]: loading Harbor images ...
Loaded image: goharbor/harbor-core:v2.11.0
Loaded image: goharbor/harbor-db:v2.11.0
Loaded image: goharbor/nginx-photon:v2.11.0
Loaded image: goharbor/trivy-adapter-photon:v2.11.0
Loaded image: goharbor/redis-photon:v2.11.0
Loaded image: goharbor/registry-photon:v2.11.0
Loaded image: goharbor/prepare:v2.11.0
Loaded image: goharbor/harbor-portal:v2.11.0
Loaded image: goharbor/harbor-log:v2.11.0
Loaded image: goharbor/harbor-jobservice:v2.11.0
Loaded image: goharbor/harbor-registryctl:v2.11.0
Loaded image: goharbor/harbor-exporter:v2.11.0[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
Clearing the configuration file: /config/portal/nginx.conf
Clearing the configuration file: /config/log/logrotate.conf
Clearing the configuration file: /config/log/rsyslog_docker.conf
Clearing the configuration file: /config/nginx/nginx.conf
Clearing the configuration file: /config/core/env
Clearing the configuration file: /config/core/app.conf
Clearing the configuration file: /config/registry/passwd
Clearing the configuration file: /config/registry/config.yml
Clearing the configuration file: /config/registryctl/env
Clearing the configuration file: /config/registryctl/config.yml
Clearing the configuration file: /config/db/env
Clearing the configuration file: /config/jobservice/env
Clearing the configuration file: /config/jobservice/config.yml
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 dirNote: stopping existing Harbor instance ...
WARN[0000] /usr/local/harbor/docker-compose.yml: `version` is obsolete
[+] Running 6/6✔ Container harbor-portal Removed 0.0s ✔ Container registryctl Removed 0.0s ✔ Container harbor-db Removed 0.0s ✔ Container registry Removed 0.0s ✔ Container harbor-log Removed 0.0s ✔ Network harbor_harbor Removed 0.1s [Step 5]: starting Harbor ...
WARN[0000] /usr/local/harbor/docker-compose.yml: `version` is obsolete
[+] Running 10/10✔ Network harbor_harbor Created 0.1s ✔ Container harbor-log Started 0.5s ✔ Container harbor-db Started 1.5s ✔ Container registryctl Started 1.6s ✔ Container harbor-portal Started 1.6s ✔ Container registry Started 1.5s ✔ Container redis Started 1.6s ✔ Container harbor-core Started 2.0s ✔ Container harbor-jobservice Started 3.6s ✔ Container nginx Started 3.6s
✔ ----Harbor has been installed and started successfully.
3.4 访问Harbor
浏览器输入ip地址,用户名默认:admin,密码是harbor.yml中配置的
-
访问地址:http://192.168.0.117/
5、docker添加安全访问权限
# 编辑/etc/docker/daemon.json文件
vim /etc/docker/daemon.json# 添加安全访问权限
{"insecure-registries":["http://192.168.0.117"]
}# 重启Docker
systemctl restart docker
创作不易,谢谢大家。随时交流
这篇关于史上最全的整合Harbor安装教程,哈哈哈哈的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!