这里选择的是企业级harbor作为私人仓库,原因在于有web界面
这里以当前最新版2.2.1为例
1.下载harbor离线安装包
到harbor的github网址https://github.com/goharbor/harbor/releases下载
离线包是第一个
2.安装高版本docker
harbor目前需要docker1.17版本以上,而centos7默认安装的docker版本是1.13,所以需要升级
需要注意升级后的docker会失去原来的容器和镜像,注意做好备份
先卸载原来的docker
yum remove docker*
安装阿里云镜像源
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装docker最新版
yum install docker-ce
3.启动docker
systemctl start docker
4.安装docker-compose
docker-compose通过配置文件管理多个docker容器
目前centos7的1.18版本足够使用,如果不行可以百度搜索高版本,本质是一个python脚本
yum install docker-compose
5.安装harbor
解压压缩包
tar xvzf harbor-offline-installer-v2.2.1.tgz
修改配置文件
这里需要注意完全没有必要使用https,吃力不讨好,所以下面只使用http
mv harbor.yml.tmpl harbor.yml
vim harbor.yml
# 修改为下面的内容
hostname: <你的服务器IP>
# http related config
http:
# port for http, default is 80. If https enabled, this port will redirect to https port
port: <默认80 可以修改为别的端口>
# 注释掉https
#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
harbor_admin_password: <设置自己的管理员密码>
安装harbor
cd harbor
./install.sh
通过http://<IP>:端口访问
6.启动关闭harbor
cd harbor # 在harbor目录下
docker-compose start/stop # 启动/关闭harbor
7.修改配置文件后生效
修改配置文件后执行install.sh脚本即可
如何推送镜像请参考如何推送docker镜像到harbor