Docker 安装部署Harbor 私有仓库
系统环境:redhat x86_64
一、首先部署docker 环境
- 定制软件源
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum install -y yum-utils device-mapper-persistent-data lvm2
- 配置下载源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 安装docker 版本
安装最新版docker
yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce
systemctl enable docker
systemctl start docker
- 修改 docker 守护进程配置文件
vim /etc/docker/daemon.json
添加内容如下:
{
"insecure-registries": ["192.168.xx.xx:5001","harbor.gzky.com"]
}
- 安装harbor 版本
手动下载安装docker-compose
cd /usr/local/bin
cp docker-compose-Linux-x86_64 docker-compose
chmod +x docker-compose-Linux-x86_64
docker-compose --version
- 下载harbor 安装包
下载软件
mkdir /data/{softs,server} -p && cd /data/softs
wget https://github.com/goharbor/harbor/releases/download/v2.5.0/harbor-offline-installer-v2.5.0.tgz
解压软件
tar -zxvf harbor-offline-installer-v2.5.0.tgz -C /data/server/
cd /data/server/harbor/
加载镜像
docker load < harbor.v2.5.0.tar.gz
docker images
备份配置
cp harbor.yml.tmpl harbor.yml
- 配置文件
修改配置
[root@kubernetes-register /data/server/harbor]# vim harbor.yml
# 修改主机名
hostname: 192.168.xx.xx
http:
port: 5001
#https: 注释ssl相关的部分
# port: 443
# certificate: /your/certificate/path
# private_key: /your/private/key/path
# 修改harbor的登录密码
harbor_admin_password: 123456
# 设定harbor的数据存储目录
data_volume: /data/server/harbor/data
- 配置harbor
配置harbor
./prepare
启动harbor
./install.sh
检查效果
docker-compose ps
- 测试harbor 仓库
docker login 192.168.xx.xx:5001 -u admin -p 123456
登录成功信息如下:
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
- 定制镜像标签
docker tag goharbor/harbor-exporter:v2.5.0 192.168.xx.xx:5001/bai_001/harbor-exporter:v2.5.0
- 登录harbor 页面
http://192.168.xx.xx:5001
- 创建harbor 项
- 上传镜像到私有仓库
docker push 192.168.xx.xx:5001/bai_001/harbor-exporter:v2.5.0
- harbot 页面查看上传镜像
- 常用命令
停止harbor
docker-compose stop
启动harbor
docker-compose start
停止并删除
docker-compose down -v
创建并启动
docker-compose up -d