官方文档:https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
1 环境依赖:docker docker-compose
Ubuntu16 可参考 https://blog.csdn.net/jinking01/article/details/82490688
其它系统可参考:http://www.runoob.com/docker/ubuntu-docker-install.html
我的服务器是在阿里云上,直接运行:
apt-get install docker.io
注:
检测安装结果:docker -v
阿里云上:apt-get install docker-compose
官网教程参考:https://docs.docker.com/compose/install/#install-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
pip install docker-compose
注:
检测安装情况:
docker-compose --version
官网地址:https://github.com/goharbor/harbor/releases
wget https://storage.googleapis.com/harbor-releases/release-1.7.0/harbor-online-installer-v1.7.1.tgz
注:下载速度太慢,可以windows上下载下来然后copy到服务器上
tar -xvf harbor-online-installer-v1.7.1.tgz
2 配置harbor
cd harbor
vim harbor.cfg
将 hostname的值修改成本机IP,比如198.127.0.1
部分配置含义:
#配置访问的地址
hostname = 198.127.0.1
#使用http方式访问管理界面
ui_url_protocol = http
#配置admin的密码,默认是Harbor12345
harbor_admin_password = 12345
#更改harbor存储路径,默认是/data
secretkey_path = /mnt/vdc/harbor_data
./install.sh
vim docker-compose.yml
例如 修改80:80 为 81:80
vim common/templates/registry/config.yml
sudo ./prepare
参考官方文档:
docker-compose up -d
(端口默认是80,nginx如果修改了端口映射(比如上面的81:80),那端口就是81):IP:Port
Eg: 198.127.0.1:81
Harbor默认用户名:admin
Harbor默认密码:Harbor12345
注:
停止Harbor:docker-compose down -v
3 修改insecure-registry
198.127.0.1:81
service docker restart
有好几种方式,主要分为 修改daemon.json增加仓库地址(推荐) 和 在docker启动文件配置仓库地址
3.2.1 和 3.2.2 二选一(推荐3.2.1,方便)
文件目录:/etc/docker/daemon.json (没有则新建该文件)
{
"insecure-registries": ["198.127.0.1:81"]
}
然后重启docker:
service docker restart
service docker status
vim /lib/systemd/system/docker.service
在ExecStart的最后增加:--insecure-registry=198.127.0.1:81
修改docker.service一定要执行systemctl daemon-reload刷新配置
systemctl daemon-reload
systemctl restart docker
4 docker push镜像:
docker login 198.127.0.1:81
输入
用户名admin
密码Harbor12345
docker tag blog:v2.0 192.127.0.1:81/tom/blog:v2.0
docker push 192.127.0.1:81/tom/blog:v2.0
push常见错误:
(1)Error response from daemon: Get https://192.127.0.1/v1/users/: dial tcp 192.127.0.1:443: getsockopt: connection refused
(2)Error response from daemon: Get https://192.127.0.1:81/v1/users/: http: server gave HTTP response to HTTPS client
原因:
1 端口错了,比如不是默认端口80,而是81
2 没有在docker启动文件中添加--insecure-registry 信任关系,解决办法在上面 3 修改insecure-registry