安装Harbor,首先要安装docker 和 docker-compose

1.安装docker
 
(1)安装一些必要的系统工具
$ yum install -y yum-utils device-mapper-persistent-data lvm2

  

(2)添加软件源信息
$ yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  

(3)更新 yum 缓存
$ yum makecache fast

 

(4)安装 Docker-ce
$ yum -y install docker-ce
 
(5)启动 Docker 后台服务
$ systemctl start docker

  

 
2.安装docker-compose
 
(1)下载二进制文件
$ curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

  

(2)赋予二进制文件可执行权限
$ chmod +x /usr/local/bin/docker-compose

  

(3)根据自己的情况决定是否安装命令补全功能
$ yum install bash-completion
$ curl -L https://raw.githubusercontent.com/docker/compose/1.16.1/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose

  

(4)测试是否安装成功
$ docker-compose --version

  

 
 
3.安装harbor
 
(1)下载
$ wget -P /usr/local/src/  https://github.com/vmware/harbor/releases/download/v1.2.0/harbor-online-installer-v1.2.0.tgz

  

(2)解压
$ tar zxf harbor-online-installer-v1.2.0.tgz  -C /usr/local/

  

(3)修改配置文件
$ cd /usr/local/harbor/
$ vim /usr/local/harbor/harbor.cfg
修改hostname = harbor (启动harbor为主机名)
否则会报异常:
➜ Please set hostname and other necessary attributes in harbor.cfg first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.
Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.cfg bacause notary must run under https.
Please set --with-clair if needs enable Clair in Harbor
 
(4)执行安装
$ ./install.sh
默认账号密码: admin / Harbor12345 登录后修改密码
 
(6)启动和重启
Harbor 的日常运维管理是通过docker-compose来完成的,Harbor本身有多个服务进程,都放在docker容器之中运行,我们可以通过docker ps命令查看。
查看Harbor
# docker-compose ps
启动Harbor
# docker-compose start
停止Harbor
# docker-comose stop
重启Harbor
# docker-compose restart
如果是用 docker-compose start 会报错:
ERROR: for nginx  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: for harbor-log  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
 
因此使用 docker-compose up -d 启动
 
 
4. 上传和下载
(1)配置daemon.json
$ vim /etc/docker/daemon.json

{
  "registry-mirrors": ["https://njrds9qc.mirror.aliyuncs.com"],
  "insecure-registries":["192.168.38.23"]
}

然后依次执行如下命令:

$ docker-compose stop
$ systemctl daemon-reload
$ systemctl restart docker
$ docker-compose up -d

 

(2)客户端将镜像打tag
命令格式:docker tag SOURCE_IMAGE[:TAG] harbor/library/IMAGE[:TAG]
docker tag 83f3f8af3613 192.168.38.23/library/tomcat:7.0.69-jre7
(3)客户端push镜像之前,先登录服务端
$ docker login 192.168.38.23
Username: admin
Password:

用户名密码:admin / Harbor12345

备注:如果登录时出现 Error response from daemon: Get http://192.168.38.23/v2/: Get http://harbor/service/token?account=admin&client_id=docker&offline_token=true&service=harbor-registry: dial tcp: lookup harbor on 192.168.38.2:53: no such host.

则需要执行第5步操作,配置TLS证书

(4)客户端push

push命令格式: docker push harbor/library/IMAGE[:TAG]

$ docker push 192.168.38.23/library/tomcat:7.0.69-jre7

  

5.Harbor配置TLS证书
 
(1)修改Harbor配置文件
因为Harbor默认使用http协议访问,所以我们这里在配置文件中,开启https配置;
配置harbor.cfg

hostname = 192.168.38.23
ui_url_protocol = https
ssl_cert = /etc/certs/ca.crt
ssl_cert_key = /etc/certs/ca.key

 
(2)创建自签名证书key文件
$ mkdir /etc/certs
$ openssl genrsa -out /etc/certs/ca.key 2048
Generating RSA private key, 2048 bit long modulus
....+++
..................................................+++
e is 65537 (0x10001)

 

(3)创建自签名证书crt文件
$ openssl req -x509 -new -nodes -key /etc/certs/ca.key -subj "/CN=192.168.38.23" -days 5000 -out /etc/certs/ca.crt
 
(4)开始安装Harbor
$ ./install.sh
(5)客户端配置
客户端需要创建证书文件存放的位置,并且把服务端创建的证书拷贝到该目录下,然后重启客户端docker
$ mkdir -p /etc/docker/certs.d/192.168.38.23

  

把服务端crt证书文件拷贝到客户端,这里的客户端为192.168.38.21
$ scp /etc/certs/ca.crt root@192.168.38.21:/etc/docker/certs.d/192.168.38.23/

 

重启客户端docker
$ systemctl restart docker

  

$ docker login 192.168.38.23
Username: admin
Password:
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 push 192.168.38.23/library/tomcat:7.0.69-jre7

push成功后登录Harbor可查看刚才上传的镜像,这里的链接地址也变成了https了 https://192.168.38.23/harbor/sign-in

(6)客户端docker pull 测试
备注:如果pull不成功,可能需要修改daemon.json 文件

CentOS7 Harbor 安装的更多相关文章

  1. Harbor 学习分享系列1 - centos7.4安装harbor1.5.2

    centos7.4安装harbor1.5.2 前言 本系列分享将Harbor有关教程:分享形式会以百度云盘的形式进行分享,主要教程将以markdown格式进行分享:建议使用markdownpad2这款 ...

  2. Centos7 docker、harbor 安装配置

    Docker 安装 wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo wget ...

  3. (一)Harbor安装 -- 企业级Registry仓库

    根据Harbor官方描述: Harbor是一个用于存储和分发Docker镜像的企业级Registry服务器,通过添加一些企业必需的功能特性,例如安全.标识和管理等,扩展了开源Docker Distri ...

  4. Harbor安装 -- 企业级Registry仓库

    (一)Harbor安装 -- 企业级Registry仓库 以下文章转自http://www.jianshu.com/p/2ebadd9a323d 根据Harbor官方描述: Harbor是一个用于存储 ...

  5. Docker私服仓库Harbor安装

    Harbor安装那里还是很简单,就是在Docker Login那里掉坑里去了,搞半天,写博客的时候,又重新安装了一遍 1.准备两台服务器 centos7 harbor 10.19.46.15 clie ...

  6. Harbor 安装教程

    Harbor 安装教程 一. CentOS设置 1. 更换阿里源 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com ...

  7. Harbor2.2.4在CentOS7.9安装、部署

    CentOS7.9基础环境配置 https://www.cnblogs.com/uncleyong/p/15471002.html 直接从网盘获取配置好的环境 修改:vim /etc/hosts 12 ...

  8. 在centos7上安装Jenkins

    在centos7上安装Jenkins 安装 添加yum repos,然后安装 sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins ...

  9. CentOS7 Jenkins安装

    CentOS7 Jenkins安装 CentOS7 Jenkins安装 Download 从Jenkins下载apache-tomcat-8.0.18.tar.gz Install 安装 上传RPM文 ...

随机推荐

  1. 微信和QQ可以关闭广告了,每次能关6个月

    微信和QQ可以关闭广告了,这次腾讯真的是良心了,虽然不能完全关闭,但是每次能关6个月,也能清静不少时间. 关闭地址:点击进入

  2. 数据解析模块BeautifulSoup简单使用

    一.准备环境: 1.准备测试页面test.html <html> <head> <title> The Dormouse's story </title> ...

  3. jmeter对tomcat性能测试

    主要对tomcat的参数做一些记录(jmeter和tomcat在同一个计算机,可能引起测试误差) 我的计算机配置  4核8线程  8G内存 案例一 tomcat  JVM  1.8G堆内存,无数据库操 ...

  4. Centos7部署分布式文件存储(Fastdfs)

    目录 FastDFS介绍 楼主目标:前可H5撩妹,后可Linux搞运维 环境:Centos7 软件: 软件链接: 安装前所有准备,上传软件到Centos7上的/opt的目录下 安装依赖软件和类库(安装 ...

  5. kolla部署openstack allinone,报错 ImportError: cannot import name decorate

    使用 kolla-ansible 部署 opnenstack:stein,最后无法导入变量脚本,报错信息如下: [root@kolla ~]# . /etc/kolla/admin-openrc.sh ...

  6. Pyqt5开发一款小工具(翻译小助手)

    翻译小助手 开发需求 首先五月份的时候,正在学习爬虫的中级阶段,这时候肯定要接触到js逆向工程,于是上网找了一个项目来练练手,这时碰巧有如何进行对百度翻译的API破解思路,仿造网上的思路,我摸索着完成 ...

  7. fatal error C1083: 无法打开包括文件: “Halcon.h”: No such file or directory

    这个文件是有包括的.但编译时报错. 解决方法:我把debug模式改为release模式就好了.

  8. centos7-cockpit

    yum install cockpit* -y systemctl start cockpit.service systemctl enable cockpit.service 修改默认端口9090 ...

  9. bind 仿造 重写bind

    简单版,不带参数 Function.prototype.my_bind = function(targ){ var _this = this; return function(){ _this.app ...

  10. 为什么说要搞定微服务架构,先搞定RPC框架

    今天开始聊一些微服务的实践,第一块,RPC框架的原理及实践,为什么说要搞定微服务架构,先搞定RPC框架呢? 一.需求缘起 服务化的一个好处就是,不限定服务的提供方使用什么技术选型,能够实现大公司跨团队 ...