从零开始安装部署Harbor(Docker+Docker-compose+Harbor)

45 篇文章 5 订阅
19 篇文章 1 订阅

1.安装docker

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl start docker

查看docker版本

docker -v

2.安装docker-compose
1)配置阿里的epel源

 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2)安装并升级Python-pip

 yum install python-pip -y
 pip install --upgrade pip

3)安装docker-compose

 pip install docker-compose

4)查看docker-compose版本

docker-compose -v

3.安装harbor
1)自己上传harbor的压缩包
harbor-offline-installer-v2.0.1
提取码:2022
2)自己解压压缩包

tar -zxvf harbor-offline-installer-v2.0.1.tgz 

3)进入到相对应的目录下

 cd harbor

4)修改harbor的配置文件(如果只想能够运行起来的话,只需要修改hostname即可,改成你机器的ip;)

cp harbor.yml.tmpl  harbor.yml
mkdir -p /opt/application/harbor     //用于存放harbor的持久化数据
harbor.yml配置文件主要修改参数如下:
hostname: 192.168.205.129         //设置访问地址,可以使用ip、域名,不可以设置为127.0.0.1或localhost。默认情况下,harbor使用的端口是80,若使用自定义的端口,除了要改docker-compose.yml文件中的配置外,这里的hostname也要加上自定义的端口,否则在docker login、push时会报错
#http配置
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: 80                     
#https配置(如不需要可不配置,注释掉)
# https related config
#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/path
#external_url: https://reg.mydomain.com:8433      //如果要启用外部代理,比如外层的NGINX、LB等,请取消注释external_url,当它启用时,hostname将不再使用。
harbor_admin_password: Harbor12345         //admin密码
#数据库配置
database:
# The password for the root user of Harbor DB. Change this before any production use.
password: root123
# The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained.
max_idle_conns: 50
# The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections.
# Note: the default number of connections is 100 for postgres.
max_open_conns: 100
#持久化数据目录
data_volume: /opt/application/harbor

5)修改Docker的配置文件

vim /etc/docker/daemon.json 
{
"registry-mirrors": ["https://cyowm7vy.mirror.aliyuncs.com"]
"insecure-registries":["192.168.205.129:80"]
}
systemctl daemon-reload 

重新启动Docker后台服务: systemctl restart docker

6)修改配置后docker-compose down停止所有服务,删除当前配置目录:rm -rf ./common/config/*下配置清单,重新执行install.sh生成配置

docker-compose down

rm -rf ./common/config/*

./install.sh

4,Harbor如何停止与启动

# cd soft/harbor       //切换到harbor安装包目录
# docker-compose stop   //停止Harbor
# docker-compose start  //启动Harbor

部分代码如下(可以直接打成一个简易命令包执行就行!):

vi dockers.sh
#i
#!/bin/bash 
# docker
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
docker -v
# docker-compose
 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
 yum install python-pip -y
 pip install --upgrade pip
 pip install docker-compose
 docker-compose -v
chmod 777 dockers.sh   #赋权
./dockers.sh           #执行权限

感谢大家,点赞,收藏,关注,评论!

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cat God 007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值