安裝Harbor1.6 企業(yè)級鏡像倉庫

Harbor 1.6 安裝

環(huán)境

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

#創(chuàng)建工作目錄

mkdir -p /home/docker_data/Harbor

#刪除軟鏈接(如果存在,請注意不要誤刪)

rm -r /data

#創(chuàng)建軟鏈接

ln -s /home/docker_data/Harbor /data

#創(chuàng)建證書目錄

mkdir /data/cert

#賦權(quán)

chmod -R 777 /home/docker_data/Harbor

chmod -R 777 /data

#創(chuàng)建證書 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茄螃,關(guān)鍵配置項

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 ,關(guān)鍵配置項

ports:

? - 8081:80

? - 8088:443

? - 4443:4443

#部署

chmod -R 777 *

./install.sh

#訪問

https://IP:8088

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

#Docker 客戶端配置

#修改HOSTS文件(非必需)

vi /etc/hosts

IP? www.harbor.com

#創(chuàng)建目錄

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

#注意W巢弧!兼耀!不必重啟 docker 服務(wù)

#登陸驗證

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

接下來向Harbor推一個鏡像:

1品嚣、首先在Harbor上創(chuàng)建一個項目”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服務(wù)器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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末眶诈,一起剝皮案震驚了整個濱河市涨醋,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌逝撬,老刑警劉巖浴骂,帶你破解...
    沈念sama閱讀 221,888評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異宪潮,居然都是意外死亡溯警,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,677評論 3 399
  • 文/潘曉璐 我一進店門狡相,熙熙樓的掌柜王于貴愁眉苦臉地迎上來愧膀,“玉大人,你說我怎么就攤上這事谣光。” “怎么了芬为?”我有些...
    開封第一講書人閱讀 168,386評論 0 360
  • 文/不壞的土叔 我叫張陵萄金,是天一觀的道長。 經(jīng)常有香客問我媚朦,道長氧敢,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,726評論 1 297
  • 正文 為了忘掉前任询张,我火速辦了婚禮孙乖,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘份氧。我一直安慰自己唯袄,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 68,729評論 6 397
  • 文/花漫 我一把揭開白布蜗帜。 她就那樣靜靜地躺著恋拷,像睡著了一般。 火紅的嫁衣襯著肌膚如雪厅缺。 梳的紋絲不亂的頭發(fā)上蔬顾,一...
    開封第一講書人閱讀 52,337評論 1 310
  • 那天宴偿,我揣著相機與錄音,去河邊找鬼诀豁。 笑死窄刘,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的舷胜。 我是一名探鬼主播娩践,決...
    沈念sama閱讀 40,902評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼逞带!你這毒婦竟也來了欺矫?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,807評論 0 276
  • 序言:老撾萬榮一對情侶失蹤展氓,失蹤者是張志新(化名)和其女友劉穎穆趴,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體遇汞,經(jīng)...
    沈念sama閱讀 46,349評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡未妹,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,439評論 3 340
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了空入。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片络它。...
    茶點故事閱讀 40,567評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖歪赢,靈堂內(nèi)的尸體忽然破棺而出化戳,到底是詐尸還是另有隱情,我是刑警寧澤埋凯,帶...
    沈念sama閱讀 36,242評論 5 350
  • 正文 年R本政府宣布点楼,位于F島的核電站,受9級特大地震影響白对,放射性物質(zhì)發(fā)生泄漏掠廓。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,933評論 3 334
  • 文/蒙蒙 一甩恼、第九天 我趴在偏房一處隱蔽的房頂上張望蟀瞧。 院中可真熱鬧,春花似錦条摸、人聲如沸悦污。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,420評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽塞关。三九已至,卻和暖如春子巾,著一層夾襖步出監(jiān)牢的瞬間帆赢,已是汗流浹背小压。 一陣腳步聲響...
    開封第一講書人閱讀 33,531評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留椰于,地道東北人怠益。 一個月前我還...
    沈念sama閱讀 48,995評論 3 377
  • 正文 我出身青樓,卻偏偏與公主長得像瘾婿,于是被迫代替她去往敵國和親蜻牢。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,585評論 2 359

推薦閱讀更多精彩內(nèi)容