赞
踩
原文连接:http://www.duozhi.online/2023/10/20/centos7%e4%b8%adharbor%e5%ae%89%e8%a3%85/
192.168.0.208
[root@MESDB-205 ~]# systemctl disable firewalld&&systemctl stop firewalld&&systemctl daemon-reload
备份原来的yum 源配置 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 查看下自己的操作 ls -l /etc/yum.repos.d 下载阿里云的centos7源 cd /etc/yum.repos.d&&wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 查看下内容 ls -l /etc/yum.repos.d 安装epel源 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 查看启用的yum源 yum repolist enabled 清理缓存 yum clean all 重新生成缓存 yum makecache
[root@MESDB-205 ~]# yum install chrony -y
[root@MESDB-205 ~]# systemctl enable chronyd
[root@MESDB-205 ~]# systemctl start chronyd
[root@MESDB-205 ~]# chronyc sources
下载docker源
[root@MES-208 yum.repos.d]# cd /etc/yum.repos.d &&wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装docker
[root@MES-208 yum.repos.d]# yum install docker-ce docker-ce-cli containerd.io -y
配置国内镜像源
[root@TRANSIT-208 yum.repos.d]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
启动并设置开机启动
[root@MES-208 yum.repos.d]# systemctl start docker&&systemctl enable docker&&systemctl daemon-reload
[root@TRANSIT-208 yum.repos.d]# yum install -y python2-pip
[root@TRANSIT-208 bin]# curl -L "https://github.com/docker/compose/releases/download/v2.1.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[root@TRANSIT-208 bin]# chmod +x /usr/local/bin/docker-compose
查看版本
[root@TRANSIT-208 bin]# docker-compose --version
Docker Compose version v2.1.1
[root@TRANSIT-208 harbor]#mkdir -p /home/harbor
[root@TRANSIT-208 harbor]# wget https://github.com/goharbor/harbor/releases/download/v2.6.1/harbor-online-installer-v2.6.1.tgz
[root@TRANSIT-208 harbor]# tar -xvf harbor-online-installer-v2.6.1.tgz
[root@TRANSIT-208 harbor]#cd harbor
[root@TRANSIT-208 harbor]# cp harbor.yml.tmpl harbor.yml
[root@TRANSIT-208 harbor]# vim harbor.yml
1)修改IP地址:
修改参数:hostname
(2)修改port端口号:
修改参数:http.port
(3)去掉https配置:
将https及其子参数都注释掉。
(4)修改admin密码:
修改参数:harbor_admin_password
(5)修改harbor数据库密码:
修改参数:database.password
(6)修改持久化数据目录:
修改参数:data_volume
[root@TRANSIT-208 harbor]# ./install.sh
查看
编写harbor的服务脚本,脚本的位置为:/etc/systemd/system,脚本的名称自定义,比如:docker-compose-harbor.service,脚本的内容如下:(WorkingDirectory为harbor的docker-compose.yml所在的路径)
[Unit] Description=Docker Compose Application Service Requires=docker.service After=docker.service [Service] Type=oneshot RemainAfterExit=yes WorkingDirectory=/home/harbor/harbor ExecStart=/usr/local/bin/docker-compose up -d ExecStop=/usr/local/bin/docker-compose down TimeoutStartSec=0 [Install] WantedBy=multi-user.target
授权脚本权限
chmod 755 /etc/systemd/system/docker-compose-harbor.service
加入开机启动
systemctl enable docker-compose-harbor
启动
systemctl start docker-compose-harbor
查看状态
systemctl status docker-compose-harbor
停止
systemctl stop docker-compose-harbor
http://192.168.0.208/harbor/projects
由于我们的harbor配置的http,所以要作如下配置,k8s节点的docker也要做如下配置并重启docker
/etc/docker/daemon.json中添加如下配置
"insecure-registries": [
"192.168.0.208"
]
登陆
docker login 192.168.0.208
用户名/密码 admin/123456
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。