docker以https方式自建私有鏡像倉(cāng)庫(kù)harbor

基礎(chǔ)環(huán)境
系統(tǒng):centos7.4
首先關(guān)閉防火墻和selinux
iptables -F
setenforce 0
docker安裝
安裝依賴包
yum install -y yum-utils device-mapper-persistent-data lvm2
安裝docker軟件包源
yum-config-manager --add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce -y
安裝docker-compase https://docs.docker.com/compose/install/
root用戶下:curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

成都創(chuàng)新互聯(lián)公司從2013年創(chuàng)立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都做網(wǎng)站、網(wǎng)站建設(shè)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元潁泉做網(wǎng)站,已為上家服務(wù),為潁泉各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575

下載harbor安裝包:https://github.com/goharbor/harbor/releases
我用的是harbor-offline-installer-v1.5.1.tgz版本 。

tar -xvf harbor-offline-installer-v1.5.1.tgz , cd harbor , mkdir ssl
然后開(kāi)始自建證書(shū), ssl目錄存放我們創(chuàng)建的證書(shū)和公私鑰等等。

openssl req -newkey rsa:4096 -nodes -sha256 -keyout ca.key -x509 -days 365 -out ca.crt
輸入國(guó)家CN, your name 可以輸入自己的名字
創(chuàng)建生成ca的根證書(shū)。

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

openssl x509 -req -days 365 -in reg.wangxinlei.com.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out reg.wangxinlei.com.crt
請(qǐng)求頒發(fā)證書(shū)
生成后的文件如下圖docker以https方式自建私有鏡像倉(cāng)庫(kù)harbor

修改配置文件 harbor.cfg
cd /root/harbor , vim harbor.cfg
hostname = reg.wxl.com #hostname 為你生成證書(shū)的時(shí)候輸入的域名
ui_url_protocol = https 協(xié)議默認(rèn)是http,修改為https

ssl_cert = ./ssl/reg.wxl.com.crt 這兩個(gè)文件路徑改為真實(shí)路徑
ssl_cert_key = ./ssl/reg.wxl.com.key

harbor_admin_password = 123456 harbor登錄的管理員密碼默認(rèn)為harbor12345 ,可以改為自己需要的密碼

systemctl start docker , 啟動(dòng)docker。
systemctl enable docker 開(kāi)機(jī)自啟docker

harbor路徑下執(zhí)行 ./prepare 準(zhǔn)備以剛才修改的內(nèi)容的配置文件
docker以https方式自建私有鏡像倉(cāng)庫(kù)harbor

在harbor路徑下執(zhí)行 ./install.sh 安裝

提示docker-compose版本需要
[root@master01 harbor]# ./install.sh

[Step 0]: checking installation environment ...

Note: docker version: 18.09.2
? Need to install docker-compose(1.7.1+) by yourself first and run this script again.

重新安裝docker-compose ,cd /usr/local/bin/, rm -rf docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

再次執(zhí)行./install.sh 安裝harbar 。
然后修改hosts文件。windows目錄:C:\Windows\System32\drivers\etc\hosts
添加 192.168..reg.wangxinlei.com ,如果沒(méi)有權(quán)限修改請(qǐng)修改文件權(quán)限。
linux系統(tǒng)在/etc/hosts 目錄添加 192.168..reg.wangxinlei.com

瀏覽器輸入 reg.wangxinlei.com
輸入配置文件內(nèi)的賬號(hào)密碼 admin 123456
docker以https方式自建私有鏡像倉(cāng)庫(kù)harbor

部署完成,下一步就是學(xué)習(xí)如何使用harbar私有倉(cāng)庫(kù)。

harbar 自帶的項(xiàng)目library 可以用來(lái)存儲(chǔ)一些公共的鏡像,這個(gè)項(xiàng)目下鏡像誰(shuí)都可以pull 下載,但是不允許push 推送。

新建用戶 :wangxl Wxl148539
進(jìn)入library項(xiàng)目,新建成員把剛才新建的用戶添加進(jìn)去。

如果是本機(jī)登錄harbar的話。先創(chuàng)建一個(gè)目錄
mkdir -p /etc/harbar/certs.d/reg.wangxinlei.com
cp /root/harbar/ssl/reg.wangxinlei.com.crt 到上面的目錄
并在/etc/hosts 添加域名解析

用戶如果需要使用harbar ,push推送docker鏡像的話,需要先登錄
登錄命令:
[root@master01 ~]# docker login reg.wangxinlei.com
Username: wangxl
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

登錄成功。

將本地鏡像上傳到鏡像倉(cāng)庫(kù)分為兩步,第一步在項(xiàng)目中標(biāo)記鏡像
第二步推送鏡像到當(dāng)前項(xiàng)目
[root@master01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 881bd08c0b08 Less than a second ago 109MB

以上面的鏡像為例子

docker tag nginx reg.wangxinlei.com/test/nginx:v1
docker push reg.wangxinlei.com/test/nginx:v1

harbar用戶手冊(cè)地址https://github.com/goharbor/harbor/blob/master/docs/user_guide.md

本文標(biāo)題:docker以https方式自建私有鏡像倉(cāng)庫(kù)harbor
文章來(lái)源:http://muchs.cn/article44/iehghe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、營(yíng)銷型網(wǎng)站建設(shè)微信公眾號(hào)、商城網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、外貿(mào)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作