2019独角兽企业重金招聘Python工程师标准>>>

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

环境:Centos 7

1.Docker环境安装 并启动本地Docker环境

#列出版本信息
yum list docker-ce --showduplicates | sort -r#安装指定版本
yum install docker-ce-17.03.0.ce-1.el7.centos#安装
yum install -y docker#启动
systemctl start docker#验证环境就绪
docker run hello-worldyum remove docker docker-common docker-selinuxyum install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm

2.安装Docker-Compose

Docker-Compose下载地址:https://github.com/docker/compose/releases/

#进入指定目录(自由指定)
cd /usr/server
#下载
curl -L https://github.com/docker/compose/releases/download/1.14.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
#可执行赋权
chmod +x /usr/local/bin/docker-compose
#查看版本验证安装
docker-compose --version

3.安装Harbor

Harbor下载地址:https://github.com/vmware/harbor/releases

选择需要的版本下载,这里选择1.1.2

#下载tar包
wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-online-installer-v1.1.2.tgz
#解压
tar zxf harbor-online-installer-v1.1.2.tgz
#解析后进入harbor目录
cd harbor

修改harbor.cfg配置文件,完整配置文件见最后附录

为简单起见我这里只修改两个位置

a.为了让外网可以访问到 修改hostname为机器的公网IP

b.修改UI管理系统的管理员密码 harbor_admin_password = admin123

保存修改后运行当前目录下的安装脚本install.sh

./install.sh

自动安装脚本会下载几个docker镜像并启动,

注意默认web服务nginx镜像绑定80端口,nginx镜像启动失败请先释放80端口。

安装完成后访问IP或者绑定的域名就可以访问到Harbor的管理界面。如下:

4.Harbor的启停

#启动
docker-compose start#停止
docker-compose stop

5.配置Docker

因为docker默认使用的是https连接,而harbor默认使用http连接,所以需要修改docker配置标志insecure registry不安全仓库的主机!
harbor也可以设置为https。

vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --insecure-registry=94.191.16.123
#只加上--insecure-registry这个参数即可#重启docker:
systemctl daemon-reload
systemctl restart docker.service

6.进阶配置

6.1 修改nginx镜像的端口

nginx镜像默认监听80端口,为安全因素或避免冲突可以改为其他端口,此处我改为8820端口

6.1.1 编辑Harbor目录下的docker-compose.yml文件(完整文件见附录二),找到nginx镜像节点 修改如下:

proxy:image: nginx:1.11.5container_name: nginxrestart: alwaysvolumes:- ./common/config/nginx:/etc/nginxports:- 8820:80- 1143:443depends_on:- mysql- registry- ui- log

6.1.2 修改common/templates/registry/config.yml文件加入8820端口:

#vim common/templates/registry/config.ymlauth:token:issuer: registry-token-issuerrealm: $ui_url:8820/service/tokenrootcertbundle: /etc/registry/root.crtservice: token-service

6.1.3 停止harbor,重新启动并生成配置文件:

docker-compose stop
./install.sh

6.1.4 修改docker启动文件,设置信任的主机与端口(第五步配置docker中修改端口80为8820):

vim /usr/lib/systemd/system/docker.service  修改如下一行
ExecStart=/usr/bin/dockerd --insecure-registry=172.16.103.99:1180

6.1.5 重新启动docker并验证:

systemctl daemon-reload
systemctl restart docker.service

登录验证

docker login 94.191.16.123:8820
Username: admin
Password:
Login Succeeded

遇到的问题:

1.安装执行install.sh报错 File "./prepare", line 60 os.makedirs(folder, mode=0600)

查原因发现在执行python 脚本 prepare时报错,prepare脚本基于python2.7 当前机器默认python环境被我改为python3.7 改回原版安装即可

mv python python3.7.2.bak
mv python2.7.bak python
python --version

附录一:harbor.cfg配置文件

## Configuration file of Harbor#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = 94.191.16.123#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = http#The password for the root user of mysql db, change this before any production use.
db_password = root123#Maximum number of job workers in job service
max_job_workers = 3 #Determine whether or not to generate certificate for the registry's token.
#If the value is on, the prepare script creates new root cert and private key
#for generating token to access the registry. If the value is off the default key/cert will be used.
#This flag also controls the creation of the notary signer's cert.
customize_crt = on#The path of cert and key files for nginx, they are applied only the protocol is set to https
ssl_cert = /data/cert/server.crt
ssl_cert_key = /data/cert/server.key#The path of secretkey storage
secretkey_path = /data#Admiral's url, comment this attribute, or set its value to NA when Harbor is standalone
admiral_url = NA#NOTES: The properties between BEGIN INITIAL PROPERTIES and END INITIAL PROPERTIES
#only take effect in the first boot, the subsequent changes of these properties
#should be performed on web ui#************************BEGIN INITIAL PROPERTIES************************#Email account settings for sending out password resetting emails.#Email server uses the given username and password to authenticate on TLS connections to host and act as identity.
#Identity left blank to act as username.
email_identity = email_server = smtp.mydomain.com
email_server_port = 25
email_username = sample_admin@mydomain.com
email_password = abc
email_from = admin <sample_admin@mydomain.com>
email_ssl = false##The initial password of Harbor admin, only works for the first time when Harbor starts.
#It has no effect after the first launch of Harbor.
#Change the admin password from UI after launching Harbor.
harbor_admin_password = admin123##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
#Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
auth_mode = db_auth#The url for an ldap endpoint.
ldap_url = ldaps://ldap.mydomain.com#A user's DN who has the permission to search the LDAP/AD server.
#If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd.
#ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com#the password of the ldap_searchdn
#ldap_search_pwd = password#The base DN from which to look up a user in LDAP/AD
ldap_basedn = ou=people,dc=mydomain,dc=com#Search filter for LDAP/AD, make sure the syntax of the filter is correct.
#ldap_filter = (objectClass=person)# The attribute used in a search to match a user, it could be uid, cn, email, sAMAccountName or other attributes depending on your LDAP/AD
ldap_uid = uid #the scope to search for users, 1-LDAP_SCOPE_BASE, 2-LDAP_SCOPE_ONELEVEL, 3-LDAP_SCOPE_SUBTREE
ldap_scope = 3 #Timeout (in seconds)  when connecting to an LDAP Server. The default value (and most reasonable) is 5 seconds.
ldap_timeout = 5#Turn on or off the self-registration feature
self_registration = on#The expiration time (in minute) of token created by token service, default is 30 minutes
token_expiration = 30#The flag to control what users have permission to create projects
#The default value "everyone" allows everyone to creates a project.
#Set to "adminonly" so that only admin user can create project.
project_creation_restriction = everyone#Determine whether the job service should verify the ssl cert when it connects to a remote registry.
#Set this flag to off when the remote registry uses a self-signed or untrusted certificate.
verify_remote_cert = on
#************************END INITIAL PROPERTIES************************
#############

附录二:docker-compose.yml

version: '2'
services:log:image: vmware/harbor-log:v1.1.2container_name: harbor-log restart: alwaysvolumes:- /var/log/harbor/:/var/log/docker/:zports:- 127.0.0.1:1514:514networks:- harborregistry:image: vmware/registry:2.6.1-photoncontainer_name: registryrestart: alwaysvolumes:- /data/registry:/storage:z- ./common/config/registry/:/etc/registry/:znetworks:- harborenvironment:- GODEBUG=netdns=cgocommand:["serve", "/etc/registry/config.yml"]depends_on:- loglogging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "registry"mysql:image: vmware/harbor-db:v1.1.2container_name: harbor-dbrestart: alwaysvolumes:- /data/database:/var/lib/mysql:znetworks:- harborenv_file:- ./common/config/db/envdepends_on:- loglogging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "mysql"adminserver:image: vmware/harbor-adminserver:v1.1.2container_name: harbor-adminserverenv_file:- ./common/config/adminserver/envrestart: alwaysvolumes:- /data/config/:/etc/adminserver/config/:z- /data/secretkey:/etc/adminserver/key:z- /data/:/data/:znetworks:- harbordepends_on:- loglogging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "adminserver"ui:image: vmware/harbor-ui:v1.1.2container_name: harbor-uienv_file:- ./common/config/ui/envrestart: alwaysvolumes:- ./common/config/ui/app.conf:/etc/ui/app.conf:z- ./common/config/ui/private_key.pem:/etc/ui/private_key.pem:z- /data/secretkey:/etc/ui/key:z- /data/ca_download/:/etc/ui/ca/:znetworks:- harbordepends_on:- log- adminserver- registrylogging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "ui"jobservice:image: vmware/harbor-jobservice:v1.1.2container_name: harbor-jobserviceenv_file:- ./common/config/jobservice/envrestart: alwaysvolumes:- /data/job_logs:/var/log/jobs:z- ./common/config/jobservice/app.conf:/etc/jobservice/app.conf:z- /data/secretkey:/etc/jobservice/key:znetworks:- harbordepends_on:- ui- adminserverlogging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "jobservice"proxy:image: vmware/nginx:1.11.5-patchedcontainer_name: nginxrestart: alwaysvolumes:- ./common/config/nginx:/etc/nginx:znetworks:- harborports:- 80:80- 443:443- 4443:4443depends_on:- mysql- registry- ui- loglogging:driver: "syslog"options:  syslog-address: "tcp://127.0.0.1:1514"tag: "proxy"
networks:harbor:external: false

转载于:https://my.oschina.net/mrpei123/blog/2989929

Harbor Docker 镜像仓库搭建相关推荐

  1. Docker 镜像仓库搭建

    一.简介 在 Docker 中,当我们执行 docker pull xxx 的时候 ,它实际上是从 registry.hub.docker.com 这个地址去查找,这就是Docker公司为我们提供的公 ...

  2. 教你如何用Harbor 私有镜像仓库搭建

        一.Harbor是什么?  Docker有个形象的比喻叫集装箱,kubernetes是舵手,而Harbor是港湾,其实是用来保存容器镜像的仓库,企业使用docker.kubernetes时,一 ...

  3. 搭建Harbor docker镜像仓库

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

  4. harbor企业级镜像仓库搭建

    前言 环境:centos 7.9 harbor-offline-installer-v2.4.3.tgz 下载harbor版本 harbor的官网:https://goharbor.io/,点下载按钮 ...

  5. 安装harbor docker镜像仓库

    准备好docker环境. 安装docker compose sudo curl -L "https://github.com/docker/compose/releases/download ...

  6. 阿里云免费个人Docker镜像仓库搭建

    1.登录 首先进入阿里云官网,如果没有注册的需要先注册,这里就不再讲解了,注册后点击右上角的登录,登录成功后点击右上角的"控制台"进入管理界面.如下图. 2.容器镜像服务 在上图管 ...

  7. 容器云系列之Docker镜像和仓库管理

    Docker镜像是Docker容器运行时的只读模板,每一个镜像由一系列的层(layers)组成,对容器的更新操作只是对顶层的可写层操作,而镜像层并没有更改.本文简要介绍了容器镜像和仓库管理和操作,通过 ...

  8. SpringCloud项目打包Docker镜像并发布到Harbor仓库

    SpringCloud项目打包Docker镜像并发布到Harbor仓库 1. Docker-compose安装 2. Harbor仓库搭建 3. Docker环境配置 4. 项目配置 1. Docke ...

  9. Harbor: 跨数据中心复制Docker镜像的开源实现

    2019独角兽企业重金招聘Python工程师标准>>> Harbor: 跨数据中心复制Docker镜像的开源实现 博客分类: docker VMware公司3月份开源了企业级Regi ...

最新文章

  1. 大型网站技术架构(七)网站的可扩展性架构
  2. 一份史上最全的深度学习资料,包括国内外顶尖学校课程以及顶会论文集
  3. 12. MySQL简单使用
  4. BackTrack5 安装中文输入法
  5. uniapp可以封装组件嘛_uniapp聊天App实例|vue+uniapp仿微信界面|红包|朋友圈
  6. 「CJOJ2573」Snake vs Block
  7. js生成vCard,以及格式参数详细说明
  8. 三角形一点到三边距离最小_三角形内有没有一个点到三边距离之和最小 -
  9. Linux内核开发_3_busybox
  10. win7安装mysql8.0.15教程_MySQL-mysql 8.0.15安装教程
  11. SHELL下如何去掉字串里的空格(或指定字符)
  12. 郭天祥 十天搞定单片机 (1)基础知识和点亮发光二极管
  13. MSP430F149 IO端口
  14. 山东理工ACM【1239】水仙花数
  15. 六度分离(floyd算法,SPFA算法,最短路—Dijkstra算法)
  16. 初中生物课堂中提升学生核心素养的有效策略
  17. rpm -q和rpm -qa|grep
  18. 防抱死制动系统(ABS)-Simulink仿真
  19. 关系抽取:图卷积网络的学习(二)(附代码)
  20. python批量删除微信好友_黑科技,Python 脚本帮你找出微信上删除你好友的人(附视频教程)...

热门文章

  1. Android 虚线实现绘制 - DashPathEffect
  2. SpringMVC基础——一个简单的例子
  3. (0049)iOS开发之数据精度处理四舍五入问题
  4. postman test 脚本
  5. java plus方法_Java中MyBatis Plus知识点总结
  6. mysql key value 排序_MySQL利用索引优化ORDER BY排序语句的方法
  7. 多屏互动电脑版_MAXHUB无线双频同屏器HDMI连接投影仪手机电视机笔记本电脑投屏器多屏互动 MAXHUB传屏盒子WB01标配2个无线传屏...
  8. HTML5新增标签与属性
  9. YII2 模型关联之 一对多
  10. css3 animation(左右摆动) (放大缩小)