• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >虚拟化 > 详解基于Harbor搭建Docker私有镜像仓库

详解基于Harbor搭建Docker私有镜像仓库

作者:Zhisheng Tian 字体:[增加 减小] 来源:互联网

本文主要包含harbor私有镜像仓库,Harbor搭建Docker私有镜像等服务器相关知识,Zhisheng Tian 希望可以进行参考

什么是 Harbor?

第一次使用这个的时候是刚进公司处理的第一个任务的时候,发现 Harbor 就是一个用于存储和分发 Docker 镜像的企业级Registry 服务器。

网上找到一个 Harbor 的架构图:

Harbor 是 VMware 公司开源的企业级 DockerRegistry 项目,项目地址为 https://github.com/vmware/harbor。其目标是帮助用户迅速搭建一个企业级的 Docker registry 服务。它以 Docker 公司开源的 registry 为基础,提供了管理UI,基于角色的访问控制(Role Based Access Control),AD/LDAP集成、以及审计日志(Auditlogging) 等企业用户需求的功能,同时还原生支持中文。Harbor 的每个组件都是以 Docker 容器的形式构建的,使用 Docker Compose 来对它进行部署。

环境准备

1、自己在腾讯云买的服务器(CentOS7.3)

2、Docker 版本:17.05.0-ce

3、Docker-compose:1.17.1

4、Harbor:1.1.2

安装 Docker

因为系统是 CentOS 7.3 ,内核啥的都已经是 3.10,所以不用担心内核升级的问题,一些操作啥的在 7.x 上操作也很方便。

yum update               //系统版本更新
vim /etc/yum.repos.d/docker.repo    //添加以下内容

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
//下面安装 Docker 引擎
yum install docker-engine -y
//安装docker引擎,此步也可作为更新docker版本的操作:先#systemctl stop docker 停止docker服务,再#yum install docker-engine 更新docker版本
systemctl enable docker.service
systemctl start  docker       //启动docker守护进程
docker info              //查看docker运行情况
docker -v              //查看版本信息

修改 Docker 配置文件 /etc/default/docker 如下:

DOCKER_OPTS="--registry-mirror=http://aad0405c.m.daocloud.io" //换成国内的镜像加速源,不然拉取镜像简直龟速,不想在吐槽了

使用 service docker restart 重启 Docker 服务即可。

或者用官方提供的方式:

安装 Docker-compose

如果是想直接命令安装也行,

下载指定版本的docker-compose

[code]
sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

对二进制文件赋可执行权限

chmod +x /usr/local/bin/docker-compose

测试下docker-compose是否安装成功

docker-compose --version

出现如下

docker-compose version 1.17.1, build 6d101fb

但是,这种方法简直龟速,幸好还有种方法,

见这里:https://docs.docker.com/compose/install/#install-compose

这种需要通过 Python 的 pip 安装

安装 pip

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
tar -vxf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
python2.7 setup.py install    //因为服务器自带 Python 2.7
easy_install-2.7 pip

安装 docker compose

pip install docker-compose
docker-compose --version  //测试安装是否成功

安装 Harbor

wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgz
#离线安装包,也是龟速,把这个下载链接用迅雷下载,速度却贼快,嘿嘿,然后再传到服务器上去,整个过程快很多!
tar -zxvf harbor-offline-installer-v1.1.2.tgz

解压缩之后,进入目录下会看到 harbor.cfg 文件,该文件就是 Harbor 的配置文件。

## Configuration file of Harbor
# hostname设置访问地址,可以使用ip、域名,不可以设置为127.0.0.1或localhost
hostname = 115.159.227.249  #这里我先配置我的服务器IP地址
# 访问协议,默认是http,也可以设置https,如果设置https,则nginx ssl需要设置on
ui_url_protocol = http
# mysql数据库root用户默认密码root123,实际使用时修改下
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.
# 启动Harbor后,管理员UI登录的密码,默认是Harbor12345
harbor_admin_password = Harbor12345
# 认证方式,这里支持多种认证方式,如LADP、本次存储、数据库认证。默认是db_auth,mysql数据库认证
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 de
pending 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
# 是否开启自注册
self_registration = on
# Token有效时间,默认30分钟
token_expiration = 30
# 用户创建项目权限控制,默认是everyone(所有人),也可以设置为adminonly(只能管理员)
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************************

启动 harbor,修改完配置文件后,在的当前目录执行./install.sh,Harbor服务就会根据当期目录下的docker-compose.yml开始下载依赖的镜像,检测并按照顺序依次启动各个服务。

启动完成后,我们访问刚设置的 hostname 即可,http://115.159.227.249/,默认是80端口,如果端口占用,我们可以去修改docker-compose.yml文件中,对应服务的端口映射。

登录 Web Harbor , 输入用户名 admin,默认密码(或已修改密码)登录系统。

我们可以看到系统各个模块

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 详解基于Harbor搭建Docker私有镜像仓库

相关文章

  • IBM KVM三特点:Linux、虚拟化与开源
  • 轻松搞定VMware虚拟机的数据恢复
  • CentOS7 Docker防火墙的简单配置教程
  • 编写最佳的Dockerfile的方法
  • Docker堆栈的管理操作详解
  • 详解vmware14Pro中ubuntu系统界面太小的问题解决
  • 服务器虚拟化基础设施:2014年争夺战
  • docker pure-ftp 搭建ftp服务器的方法
  • 云中的开源KVM是什么样?
  • 详解基于Harbor搭建Docker私有镜像仓库

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • 利用docker搭建php7和nginx运行环境全过程(官方镜像)
    • VMware网络连接模式(桥接、NAT以及仅主机模式的详细介绍和区别)
    • 详解consul的安装和配置
    • docker 容器上编译 go 程序提示找不到文件问题
    • Spark三种属性配置方式详解
    • 利用OpenVSwitch在多台主机上部署Docker的教程
    • 用Docker安装Gitlab的方法步骤
    • 虚拟机实现静态IP登录和无线上网
    • 如何在Hyper-V虚拟机上安装WSUS服务器技巧
    • 详解Docker Registry之删除镜像、垃圾回收

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有