安装Harbor1.6 企业级镜像仓库

Harbor 1.6 安装

环境

Centos:CentOSLinuxrelease7.5.1804Docker:Dockerversion18.06.1-ce,builde68fc7aDocker-composer:docker-composeversion1.20.0,buildca8d3c6Harbor:harbor-online-installer-v1.6.0.tgz

docker-composer

$ curl -Lhttps://github.com/docker/compose/releases/download/1.20.0/docker-compose-`uname -s`-`uname -m`>/usr/local/bin/docker-compose$ chmod +x /usr/local/bin/docker-compose

download harbor

选择在线安装方式,离线版本也可以,就是在安装包比较大

$ wgethttps://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-online-installer-v1.6.0.tgz

解压并配置harbor

#创建工作目录

mkdir -p /home/docker_data/Harbor

#删除软链接(如果存在,请注意不要误删)

rm -r /data

#创建软链接

ln -s /home/docker_data/Harbor /data

#创建证书目录

mkdir /data/cert

#赋权

chmod -R 777 /home/docker_data/Harbor

chmod -R 777 /data

#创建证书 www.harbor.com

1[root@www cert]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout /data/cert/ca.key -x509 -days 3650 -out /data/cert/ca.crt

----------------------------------------------------------------------------------------------------------------

Generating a 4096 bit RSA private key

...........................................................................................................................................++

................................++

writing new private key to '/data/cert/ca.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) [XX]:CN

State or Province Name (full name) []:bj

Locality Name (eg, city) [Default City]:bj

Organization Name (eg, company) [Default Company Ltd]:bj

Organizational Unit Name (eg, section) []:bj

Common Name (eg, your name or your server's hostname) []:www.harbor.com

Email Address []:test@bj.com.cn

-----------------------------------------------------------------------------------------------------------------------------------------------

[root@www cert]# openssl req -newkey rsa:4096 -nodes -sha256 -keyout /data/cert/www.harbor.com.key -out /data/cert/www.harbor.com.csr

-----------------------------------------------------------------------------------------------------------------------------------------------

Generating a 4096 bit RSA private key

............++

............................................++

writing new private key to '/data/cert/www.harbor.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) [XX]:CN

State or Province Name (full name) []:bj

Locality Name (eg, city) [Default City]:bj

Organization Name (eg, company) [Default Company Ltd]:bj

Organizational Unit Name (eg, section) []:bj

Common Name (eg, your name or your server's hostname) []:www.harbor.com

Email Address []:test@bj.com.cn

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:

------------------------------------------------------------------------------------------------------------------------------------------

3[root@www cert]# openssl x509 -req -days 3650 -in /data/cert/www.harbor.com.csr -CA /data/cert/ca.crt -CAkey /data/cert/ca.key -CAcreateserial -out /data/cert/www.harbor.com.crt

------------------------------------------------------------------------------------------------------------------------------------------

Signature ok

subject=/C=CN/ST=bj/L=bj/O=bj/OU=bj/CN=www.bj.harbor.com/emailAddress=test@bj.com.cn

Getting CA Private Key

解压并配置harbor

$ tar xf  harbor-online-installer-v1.6.0.tgz$ cd harbor

#配置harbor.cfg,关键配置项

hostname = www.harbor.com:8088

ui_url_protocol = https

ssl_cert = /data/cert/www.harbor.com.crt

ssl_cert_key = /data/cert/www.harbor.com.key

harbor_admin_password = Harbor123456

#配置 docker-compose.yml ,关键配置项

ports:

  - 8081:80

  - 8088:443

  - 4443:4443

#部署

chmod -R 777 *

./install.sh

#访问

https://IP:8088

https://www.harbor.com:8088 (需配置hosts或搭建DNS服务器)

#Docker 客户端配置

#修改HOSTS文件(非必需)

vi /etc/hosts

IP  www.harbor.com

#创建目录

mkdir /etc/docker/certs.d

mkdir /etc/docker/certs.d/www.harbor.com:8088

# 拷贝ca.crt到/etc/docker/certs.d/www.harbor.com:8089

chmod 777 /etc/docker/certs.d/www.harbor.com:8088/ca.crt

cp -f /etc/docker/certs.d/www.harbor.com:8088/ca.crt /etc/pki/ca-trust/source/anchors/ca.crt

证书只是用于https所有

update-ca-trust

#注意!!!不必重启 docker 服务

#登陆验证

docker login --username=admin --password=Harbor123456 www.harbor.com:8088/

接下来向Harbor推一个镜像:

1、首先在Harbor上创建一个项目”bj”。(推荐不要用admin用户,新建一个用户)

2、查看本地的镜像:

root@docker:~# docker images

REPOSITORY          TAG                IMAGE ID            CREATED            SIZE

jenkins            2.112              21d71a370755        4 months ago        815MB

rancher            v1.6.11            6c4395b5515a        8 months ago        970MB

3、给”jenkins”这个镜像打上tag:

docker tag 21d71a370755 www.harbor.com:8088/bj/jenkins:2.112

4、推送至Harbor:

root@docker:~# docker push www.harbor.com:8088/bj/jenkins:2.112

The push refers to a repository [www.harbor.com:8088/bj/jenkins]

1206d45cbbbb: Pushed

c5a57a65b805: Pushed

482ab61ab3ea: Pushed

7d7236ad0e61: Pushed

4b622a1887bb: Pushed

13f00c4fe026: Pushed

6a9badfe78e2: Pushed

d0c4c512b2e9: Pushed

34d2a7a215ad: Pushed

29ebe0863109: Pushed

43591c877745: Pushed

e95144644244: Pushed

d35dd2235ffe: Pushed

88b33af4b42c: Pushed

a6b86e3ee470: Pushed

7e912d203101: Pushed

638babc3b650: Pushed

0ef6a87794b5: Pushed

20c527f217db: Pushed

61c06e07759a: Pushed

bcbe43405751: Pushed

e1df5dc88d2c: Pushed

2.112: digest: sha256:30ff8d6c06d287fcf79f28bb93a98ba07f3a275b10f8e85bb0d9e122797b06bc size: 4919

5.在Harbor上bj项目下可以看到这个镜像

6.拉取上传的镜像 (重要:要是客户端要配置hosts文件本地重定向至harbor服务器IP)

[root@www home]# docker pull www.harbor.com:8088/bj/jenkins:2.112

2.112: Pulling from bj/jenkins

c73ab1c6897b: Pull complete

1ab373b3deae: Pull complete

b542772b4177: Pull complete

57c8de432dbe: Pull complete

da44f64ae999: Pull complete

0bbc7b377a91: Pull complete

1b6c70b3786f: Pull complete

48010c1717c7: Pull complete

7a6123cacadf: Pull complete

0328005fa00f: Pull complete

0fea27bea434: Pull complete

3637d4ffed7f: Pull complete

0955f498aa90: Pull complete

61dd5dfd4199: Pull complete

e32c19b28f74: Pull complete

bf2f3fca31b5: Pull complete

c3d384d8681a: Pull complete

0fa50f757ae4: Pull complete

f4be1cdbaa43: Pull complete

67107c2a412f: Pull complete

80dd755e5377: Pull complete

00a55451a86f: Pull complete

Digest: sha256:30ff8d6c06d287fcf79f28bb93a98ba07f3a275b10f8e85bb0d9e122797b06bc

Status: Downloaded newer image for www.harbor.com:8088/bj/jenkins:2.112

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,053评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,527评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,779评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,685评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,699评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,609评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,989评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,654评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,890评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,634评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,716评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,394评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,976评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,950评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,191评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,849评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,458评论 2 342

推荐阅读更多精彩内容