起始目录/root,root 登陆后,直接在该目录进行下面的命令

下载harbor 预编译包 0.4.5

准备通过域名 reg.server.com 来访问镜像库所以需要在/etc/hosts 文件中加入 192.168.10.90 reg.server.com, IP 镜像服务器的地址。

1 生成 CA 证书(注意内容不能乱填)

openssl req -newkey rsa:4096 -nodes -sha256 -keyout ca.key -x509 -days 365 -out ca.crt

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:beijing
Locality Name (eg, city) []:beijing
Organization Name (eg, company) [Internet Widgits Pty Ltd]:reg.server.com
Organizational Unit Name (eg, section) []:reg.server.com
Common Name (e.g. server FQDN or YOUR name) []:reg.server.com # 这里最重要,一定要填写你准备使用的域名
Email Address []:admin@reg.server.com

命令完成后生成ca.crt, ca.key文件

2 然后生成CA 签名,注意文件名称要与你的域名匹配

 openssl req -newkey rsa:4096 -nodes -sha256 -keyout reg.server.com.key -out reg.server.com.csr

输入的内容如下

writing new private key to 'reg.server.com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:beijing
Locality Name (eg, city) []:beijing
Organization Name (eg, company) [Internet Widgits Pty Ltd]:reg.server.com
Organizational Unit Name (eg, section) []:reg.server.com
Common Name (e.g. server FQDN or YOUR name) []:reg.server.com # 必须和域名一致
Email Address []:admin@reg.server.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:    #密码留空即可
An optional company name []:

命令完成后生成

reg.server.com.key 和 reg.server.com.csr

3 生成证书

可以查看/etc/ssl/openssl.cnf 配置文件中 ssl 默认的文件夹名称是什么,一般来说,没被改动过的话是demoCA.

3.1 创建文件夹和辅助内容

 mkdir demoCA
cd demoCA
touch index.txt
echo '01' > serial
cd ..

3.2 签名证书

因为我们生成签名的时候使用的是FQDN 所以需要如下命令

echo subjectAltName = IP:192.168.10.90 > extfile.cnf
openssl ca -in reg.server.com.csr -out reg.server.com.crt -cert ca.crt -keyfile ca.key -extfile extfile.cnf -outdir .

3.3 讲生成的证书加入本机信任

运行3.2 的命令之后,会生成一个01.pem 和 reg.server.com.crt的证书。

cat 01.pem >> reg.server.com.crt
cp ca.crt reg.server.com.crt /usr/local/share/ca-certificates/
update-ca-certificates 

4 安装Docker(如果在导入信任证书前安装了docker, 需要重启docker,命令为 service docker restart

安装方法参见

https://docs.docker.com/engine/installation/Linux/ubuntulinux/

5 安装docker compose

安装方法参见

https://docs.docker.com/compose/install/

如果遇到伟大的长城问题。

可以直接爬墙把docker-compose-Linux-x64 文件下载下来。然后chmod +x 就可以了,然后在把这个文件改名为docker-compose 复制到/usr/local/bin 下,就算安装完成。

6 配置harbor

解压安装包

tar -zxvf harbor-offline-installer-0.4.5.tgz

修改 harbor.cfg 文件为

  1. ## Configuration file of Harbor
  2. #The IP address or hostname to access admin UI and registry service.
  3. #DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
  4. hostname = reg.server.com #必须和签名时的域名一致
  5. #The protocol for accessing the UI and token/notification service, by default it is http.
  6. #It can be set to https if ssl is enabled on nginx.
  7. ui_url_protocol = https
  8. #Email account settings for sending out password resetting emails.
  9. email_server = smtp.mydomain.com
  10. email_server_port = 25
  11. email_username = sample_admin@mydomain.com
  12. email_password = abc
  13. email_from = admin <sample_admin@mydomain.com>
  14. email_ssl = false
  15. ##The initial password of Harbor admin, only works for the first time when Harbor starts.
  16. #It has no effect after the first launch of Harbor.
  17. #Change the admin password from UI after launching Harbor.
  18. harbor_admin_password = Harbor12345   #密码可以随便改
  19. ##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
  20. #Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
  21. auth_mode = db_auth
  22. #The url for an ldap endpoint.
  23. ldap_url = ldaps://ldap.mydomain.com
  24. #A user's DN who has the permission to search the LDAP/AD server.
  25. #If your LDAP/AD server does not support anonymous search, you should configure this DN and ldap_search_pwd.
  26. #ldap_searchdn = uid=searchuser,ou=people,dc=mydomain,dc=com
  27. #the password of the ldap_searchdn
  28. #ldap_search_pwd = password
  29. #The base DN from which to look up a user in LDAP/AD
  30. ldap_basedn = ou=people,dc=mydomain,dc=com
  31. #Search filter for LDAP/AD, make sure the syntax of the filter is correct.
  32. #ldap_filter = (objectClass=person)
  33. # 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
  34. ldap_uid = uid
  35. #the scope to search for users, 1-LDAP_SCOPE_BASE, 2-LDAP_SCOPE_ONELEVEL, 3-LDAP_SCOPE_SUBTREE
  36. ldap_scope = 3
  37. #The password for the root user of mysql db, change this before any production use.
  38. db_password = root123
  39. #Turn on or off the self-registration feature
  40. self_registration = on
  41. #Determine whether the UI should use compressed js files.
  42. #For production, set it to on. For development, set it to off.
  43. use_compressed_js = on
  44. #Maximum number of job workers in job service
  45. max_job_workers = 3
  46. #The expiration time (in minute) of token created by token service, default is 30 minutes
  47. token_expiration = 30
  48. #Determine whether the job service should verify the ssl cert when it connects to a remote registry.
  49. #Set this flag to off when the remote registry uses a self-signed or untrusted certificate.
  50. verify_remote_cert = on
  51. #Determine whether or not to generate certificate for the registry's token.
  52. #If the value is on, the prepare script creates new root cert and private key
  53. #for generating token to access the registry. If the value is off, a key/certificate must
  54. #be supplied for token generation.
  55. customize_crt = on
  56. #Information of your organization for certificate
  57. crt_country = CN
  58. crt_state = State
  59. crt_location = CN
  60. crt_organization = organization
  61. crt_organizationalunit = organizational unit
  62. crt_commonname = example.com
  63. crt_email = example@example.com
  64. #The path of cert and key files for nginx, they are applied only the protocol is set to https
  65. ssl_cert = /etc/nginx/cert/reg.server.com.crt       #文件位置不能变,必须是这个位置
  66. ssl_cert_key = /etc/nginx/cert/reg.server.com.key   #文件位置不能变,必须是这个位置

修改prepare 源码(此步骤 仅仅在 ubuntu 16 中才需要执行)

vim /root/harbor/prepare 在第46 行不兼容python 3.5, ubuntu 16 默认时使用的python 3.5

将原来的 os.makedirs(path, mode=0600) 改为 os.makedirs(path, mode=0o600)  不然会报错。

备份 nginx 配置文件

mv /root/harbor/common/config/nginx/nginx.conf /root/harbor/common/config/nginx/nginx.conf.bak

拷贝 https 的配置文件到 /root/harbor/common/config/nginx/

cp /root/harbor/common/templates/nginx/nginx.https.conf /root/harbor/common/config/nginx/nginx.conf

拷贝证书

cp reg.server.com.crt reg.server.com.key /etc/nginx/cert/ (如果文件夹不存在,手动创建)

cp reg.server.com.crt reg.server.com.key /root/harbor/common/config/nginx/cert/

安装harbore

cd /root/harbor

./install.sh

安装完成后运行

docker ps 查看启动的容器,一共有6个

docker login reg.server.com (输入用户名密码,如果能成功登陆就成功 了)

过程中遇到的问题

x509: certificate signed by unknown authority

如果遇到这个问题,就是ca.crt 没有导入到本机信任列表中,运行下面命令解决

cp ca.crt /usr/local/share/ca-certificates/
update-ca-certificates 

参考文档

https://github.com/vmware/harbor/blob/master/docs/configure_https.md

https://mritd.me/2016/09/15/Harbor-%E4%BC%81%E4%B8%9A%E7%BA%A7-Docker-Registry-%E7%AC%AC%E4%BA%8C%E5%BC%B9/

ubuntu 14.04 https 形式安装docker 私有库 harbor的更多相关文章

  1. 阿里云 ubuntu 14.04 模板上安装 docker

    ubuntu 14.04 的内核是 3.13 ,所以内核不用升级. 安装过程例如以下: # apt-get update # apt-get install apt-transport-https # ...

  2. Ubuntu 14.04 LTS下安装Google Chrome浏览器

    在Ubuntu 14.04下安装Google Chrome浏览器非常简单,只要到Chrome的网站下载Deb安装包并进行安装即可.当然你也可以使用APT软件包管理器来安装Google Chrome浏览 ...

  3. ubuntu 14.04 64位安装iNodeClient

    ubuntu 14.04 64位安装iNodeClieng(华三校园客服端) http://pan.baidu.com/s/12dpxk ubuntu 14.04 64bit Install H3C ...

  4. Ubuntu 14.04 下手动安装Firefox的Flash插件

    有时候我们不得不採用手动安装一些软件. Ubuntu 14.04 下手动安装Firefox的Flash插件有下面几步 1. 下载Flash插件 下载地址为http://get.adobe.com/cn ...

  5. 基于Ubuntu 14.04构建mysql5.6 Docker镜像

    我们的目的是创建一个基于Ubuntu 14.04 的MySQL的 Docker Image,并且在新创建出来的容器里自动启动MySQL服务接受外部连接 步骤: 1. 首先创建一个目录并在目录下创建一个 ...

  6. Ubuntu 14.04 python3.6 安装

    参考 how-do-i-install-python-3-6-using-apt-get Ubuntu 14.04 python3.6 安装 sudo add-apt-repository ppa:j ...

  7. Linux ->> UBuntu 14.04 LTE下安装Hadoop 1.2.1(伪分布模式)

    Hadoop的运行模式可分为单机模式.伪分布模式和分布模式. 首先无论哪种模式都需要安装JDK的,这一步之前的随笔Ubuntu 14.04 LTE下安装JDK 1.8中已经做了.这里就不多说了. 其次 ...

  8. 在Ubuntu 14.04 64bit上安装numpy和matplotlib库

    原文:http://blog.csdn.net/tao_627/article/details/44004541 按照这个成功安装! 机器学习是数据挖掘的一种实现形式,在学习<机器学习实战> ...

  9. 在Ubuntu 14.04 64bit上安装Markdown和绘图软件Haroopad

    简介 Haroopad:一款让你欲罢不能的Markdown编辑器 身为大程序员,我本来是不需要 Markdown 编辑器的,但是 Haroopad 让我简直欲罢不能,不能再爱更多.跨平台,代码高亮,V ...

随机推荐

  1. Java基础算法集50题

    最近因为要准备实习,还有一个蓝桥杯的编程比赛,所以准备加强一下算法这块,然后百度了一下java基础算法,看到的都是那50套题,那就花了差不多三个晚自习的时间吧,大体看了一遍,做了其中的27道题,有一些 ...

  2. makefile中的自动化变量$@,$%,$

    转自:http://www.2cto.com/os/201302/191344.html   makefile中的自动化变量$@,$%,$   自动化变量  模式规则中,规则的目标和依赖文件名代表了一 ...

  3. Linux运维

    概要:http://os.51cto.com/art/201312/423616.htm 论坛: http://www.linux360.cn/ https://www.centos.bz/ http ...

  4. FastReport for delphi xe 安装步骤

    FastReport for delphi xe 安装步骤 1.先关闭DELPHI:2.下载后解压到一个目录,比如:D:FR:3.打开D:FR,运行recompile.exe ->点击" ...

  5. 国密SM4对称算法实现说明(原SMS4无线局域网算法标准)

    国密SM4对称算法实现说明(原SMS4无线局域网算法标准) SM4分组密码算法,原名SMS4,国家密码管理局于2012年3月21日发布:http://www.oscca.gov.cn/News/201 ...

  6. Linux用户名显示-bash-4.1$快速排查

    最近项目使用的的服务器有点多(100多台),很多开发同事经常问这个问题,现在整理如下: 几个可能导致的原因: 1 用户的家目录所属组被改为root,解决方法使用root执行cd /home/;chow ...

  7. Android之webView入门

    WebView可以使得网页轻松的内嵌到app里,还可以直接跟js相互调用. webview有两个方法:setWebChromeClient 和 setWebClient setWebClient:主要 ...

  8. Primace 5.0软件与KEIL单片机软件联合在线仿真步骤

    Primace 软件是CME(京微雅格)公司的FPGA芯片开发专用软件.因为CME的FPGA,如M5.M7等内嵌有8051核,所以可以和MCU联合在线仿真,虽然FPGA内的程序不可控,不能一步一步的仿 ...

  9. linux中的解压,压缩命令

    tar命令 解包:tar zxvf FileName.tar 打包:tar czvf FileName.tar DirName gz命令 解压1:gunzip FileName.gz 解压2:gzip ...

  10. [图文详解] Sublime Text在Windows/Ubuntu/Mac OSX中配置使用CTags

    很开发者都在找Sublime Text中函数转跳的功能,这个是软件自身没有的功能,要靠CTags这个插件配合CTags的可执行程序的实现的.按照我的理解是CTags扫描索引你的项目文件,然后subli ...