Harbor部署私有镜像仓库
认识:
Harbor 是一个用于存储和分发 Docker 镜像的企业级 Registry 服务器。
部署环境:
- CentOS7
- Python2.7.5
- Docker CE18.09.6
- Docker Compose1.32.2
- Harbor1.7.1
安装:
- 安装组件
yum -y install wget python-devel libevent-devel epel-release python-pip gcc gcc-c++ xz-devel
- 安装Dcoker CE
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo yum -y install docker-ce
- 安装Dcoker compose
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
- 安装Harbor
cd /usr/local/src wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-offline-installer-v1.7.1.tgz # 解压缩到目录/usr/local/harbor tar -xvf harbor-offline-installer-v1.7.1.tgz -C /usr/local/
- 编辑配置文件
cd /usr/local/harbor/ vi harbor.cfg ''' hostname = test.harbor.com project_creation_restriction = adminonly '''
- 安装服务
./install.sh
- 启动服务
docker-compose start
- 配置HTTPS
# 创建目录 mkdir -p /data/cert/ # 生成ca证书和签名 openssl genrsa -out /data/cert/ca.key 2048 openssl req -x509 -new -nodes -key /data/cert/ca.key -subj "/CN=test.harbor.com" -days 5000 -out /data/cert/ca.crt # 编辑配置文件 vi harbor.cfg ui_url_protocol = https # 启动服务 ./prepare docker-compose down docker-compose up -d
- 测试
windows:
# 配置文件位置 C:WindowsSystem32driversetchosts # 添加一行内容 ip servername
ubuntu:
# 配置文件位置 /etc/hosts # 添加一行内容 ip servername
- 访问
# 在浏览器中访问 https://test.harbor.com/ 默认用户名:admin 默认密码:Harbor12345