跳到主要内容

实战-使用harbor搭建Docker私有仓库-v2.6.2-2023.7.3-测试成功

实战:使用harbor搭建Docker私有仓库(v2.6.2)-2023.7.3(测试成功)

image-20230703071936352

目录

[toc]

推荐文章

https://www.yuque.com/xyy-onlyone/aevhhf?# 《玩转Typora》

image-20230624094222589

实验环境

dockerce 24.0.2
harbor-offline-installer-v2.6.2
docker-compose-Linux-x86_64 v1.26.2

实验软件

链接:https://pan.baidu.com/s/1y2R9mHSQ6oNk5REj_Pj5SQ?pwd=0820 提取码:0820

2023.7.3-实战:使用harbor搭建Docker私有仓库(v2.6.2)-(测试成功)

image-20230703072326387

1、安装docker-compose

github 地址:https://github.com/docker/compose/releases/

下载二进制文件上传至 linux(课程资料已提供 docker-compose 二进制文件可直接上传)

[root@harbor ~]# rz
[root@harbor ~]# ll -h docker-compose-Linux-x86_64
-r-------- 1 root root 12M 724 2020 docker-compose-Linux-x86_64

[root@harbor ~]# mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
[root@harbor ~]# chmod +x /usr/local/bin/docker-compose #添加执行权限
  • 验证
[root@harbor ~]#docker-compose
Define and run multi-container applications with Docker.

Usage:
docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
docker-compose -h|--help

Options:
-f, --file FILE Specify an alternate compose file
(default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name
(default: directory name)
-c, --context NAME Specify a context name
--verbose Show more output
……

2、安装harbor

1.下载 Harbor 安装包

image-20230703063152811

image-20230703063214217

https://github.com/goharbor/harbor/releases/download/v2.6.2/harbor-offline-installer-v2.6.2.tgz

wget https://github.com/goharbor/harbor/releases/download/v2.6.2/harbor-offline-installer-v2.6.2.tgz

注:此文件有769M 左右大小,建议大家提前下载好后,上传到 linux 系统上。

  • 解压
[root@harbor ~]#ll -h harbor-offline-installer-v2.6.2.tgz 
-rw-r--r-- 1 root root 770M Jul 3 06:34 harbor-offline-installer-v2.6.2.tgz
[root@harbor ~]#tar xf harbor-offline-installer-v2.6.2.tgz -C /opt/

2.配置 Harbor

[root@harbor ~]#cd /opt/harbor/
[root@harbor harbor]#ls
common.sh harbor.v2.6.2.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
[root@harbor harbor]#cp harbor.yml.tmpl harbor.yml #harbor的配置文件为harbor.yml

[root@harbor harbor]#vim harbor.yml
# 修改点1:hostname 设置访问地址,可以使用 ip、域名,不可以设置为 127.0.0.1 或 localhost
5 hostname: reg.mydomain.com
改为:
5 hostname: 172.29.9.120

# 修改点2:注释https相关信息
#将https全部注释
12 # https related config
13 #https:
14 # https port for harbor, default is 443
15 # port: 443
16 # The path of cert and key files for nginx
17 #certificate: /your/certificate/path
18 #private_key: /your/private/key/path

#默认登录密码是Harbor12345 (账户:admin)

修改完成后,保存退出。

⚠️ 注意:新版本这里的数据库路径为/data,默认为自己创建的,不需要我们手动创建。

image-20230703071431765

3.启动服务

[root@harbor ~]#cd /opt/harbor/
[root@harbor harbor]#ls
common.sh harbor.v2.6.2.tar.gz harbor.yml.tmpl install.sh LICENSE prepare
[root@harbor harbor]#./prepare
[root@harbor harbor]#./install.sh

#验证
[root@harbor harbor]#docker-compose ps #(9个容器)
Name Command State Ports
-----------------------------------------------------------------------------------------------------------------
harbor-core /harbor/entrypoint.sh Up (health: starting)
harbor-db /docker-entrypoint.sh 96 13 Up (health: starting)
harbor-jobservice /harbor/entrypoint.sh Up (health: starting)
harbor-log /bin/sh -c /usr/local/bin/ ... Up (health: starting) 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up (health: starting)
nginx nginx -g daemon off; Up (health: starting) 0.0.0.0:80->8080/tcp,:::80->8080/tcp
redis redis-server /etc/redis.conf Up (health: starting)
registry /home/harbor/entrypoint.sh Up (health: starting)
registryctl /home/harbor/start.sh Up (health: starting)

#配置开机自启
vim /etc/rc.local
[root@harbor ~]#vim /etc/rc.local
/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml up -d
[root@harbor ~]#chmod +x /etc/rc.local /etc/rc.d/rc.local

image-20230703071541919

3、登录

http://172.29.9.120/

账户密码:admin/Harbor12345

image-20230703071010836

安装完成。

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码 x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号 《云原生架构师实战》

image-20230107215126971

🍀 语雀

https://www.yuque.com/xyy-onlyone

image-20230624093747671

🍀 csdn https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎 https://www.zhihu.com/people/foryouone

image-20230107215203185

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!