最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

詳解基于Harbor搭建Docker私有鏡像倉庫

 更新時(shí)間:2017年12月16日 10:22:23   作者:Zhisheng Tian  
這篇文章主要介紹了詳解基于Harbor搭建Docker私有鏡像倉庫,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

什么是 Harbor?

第一次使用這個(gè)的時(shí)候是剛進(jìn)公司處理的第一個(gè)任務(wù)的時(shí)候,發(fā)現(xiàn) Harbor 就是一個(gè)用于存儲(chǔ)和分發(fā) Docker 鏡像的企業(yè)級(jí)Registry 服務(wù)器。

網(wǎng)上找到一個(gè) Harbor 的架構(gòu)圖:

Harbor 是 VMware 公司開源的企業(yè)級(jí) DockerRegistry 項(xiàng)目,項(xiàng)目地址為 https://github.com/vmware/harbor。其目標(biāo)是幫助用戶迅速搭建一個(gè)企業(yè)級(jí)的 Docker registry 服務(wù)。它以 Docker 公司開源的 registry 為基礎(chǔ),提供了管理UI,基于角色的訪問控制(Role Based Access Control),AD/LDAP集成、以及審計(jì)日志(Auditlogging) 等企業(yè)用戶需求的功能,同時(shí)還原生支持中文。Harbor 的每個(gè)組件都是以 Docker 容器的形式構(gòu)建的,使用 Docker Compose 來對(duì)它進(jìn)行部署。

環(huán)境準(zhǔn)備

1、自己在騰訊云買的服務(wù)器(CentOS7.3)

2、Docker 版本:17.05.0-ce

3、Docker-compose:1.17.1

4、Harbor:1.1.2

安裝 Docker

因?yàn)橄到y(tǒng)是 CentOS 7.3 ,內(nèi)核啥的都已經(jīng)是 3.10,所以不用擔(dān)心內(nèi)核升級(jí)的問題,一些操作啥的在 7.x 上操作也很方便。

yum update               //系統(tǒng)版本更新
vim /etc/yum.repos.d/docker.repo    //添加以下內(nèi)容

[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服務(wù),再#yum install docker-engine 更新docker版本
systemctl enable docker.service
systemctl start  docker       //啟動(dòng)docker守護(hù)進(jìn)程
docker info              //查看docker運(yùn)行情況
docker -v              //查看版本信息

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

復(fù)制代碼 代碼如下:

DOCKER_OPTS="--registry-mirror=http://aad0405c.m.daocloud.io" //換成國內(nèi)的鏡像加速源,不然拉取鏡像簡直龜速,不想在吐槽了

使用 service docker restart 重啟 Docker 服務(wù)即可。

或者用官方提供的方式:

復(fù)制代碼 代碼如下:
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://ef017c13.m.daocloud.io[/code]

安裝 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

對(duì)二進(jìn)制文件賦可執(zhí)行權(quán)限

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

測試下docker-compose是否安裝成功

docker-compose --version

出現(xiàn)如下

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    //因?yàn)榉?wù)器自帶 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
#離線安裝包,也是龜速,把這個(gè)下載鏈接用迅雷下載,速度卻賊快,嘿嘿,然后再傳到服務(wù)器上去,整個(gè)過程快很多!
tar -zxvf harbor-offline-installer-v1.1.2.tgz

解壓縮之后,進(jìn)入目錄下會(huì)看到 harbor.cfg 文件,該文件就是 Harbor 的配置文件。

## Configuration file of Harbor
# hostname設(shè)置訪問地址,可以使用ip、域名,不可以設(shè)置為127.0.0.1或localhost
hostname = 115.159.227.249  #這里我先配置我的服務(wù)器IP地址
# 訪問協(xié)議,默認(rèn)是http,也可以設(shè)置https,如果設(shè)置https,則nginx ssl需要設(shè)置on
ui_url_protocol = http
# mysql數(shù)據(jù)庫root用戶默認(rèn)密碼root123,實(shí)際使用時(shí)修改下
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.
# 啟動(dòng)Harbor后,管理員UI登錄的密碼,默認(rèn)是Harbor12345
harbor_admin_password = Harbor12345
# 認(rèn)證方式,這里支持多種認(rèn)證方式,如LADP、本次存儲(chǔ)、數(shù)據(jù)庫認(rèn)證。默認(rèn)是db_auth,mysql數(shù)據(jù)庫認(rèn)證
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
# 是否開啟自注冊(cè)
self_registration = on
# Token有效時(shí)間,默認(rèn)30分鐘
token_expiration = 30
# 用戶創(chuàng)建項(xiàng)目權(quán)限控制,默認(rèn)是everyone(所有人),也可以設(shè)置為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************************

啟動(dòng) harbor,修改完配置文件后,在的當(dāng)前目錄執(zhí)行./install.sh,Harbor服務(wù)就會(huì)根據(jù)當(dāng)期目錄下的docker-compose.yml開始下載依賴的鏡像,檢測并按照順序依次啟動(dòng)各個(gè)服務(wù)。

啟動(dòng)完成后,我們?cè)L問剛設(shè)置的 hostname 即可,http://115.159.227.249/,默認(rèn)是80端口,如果端口占用,我們可以去修改docker-compose.yml文件中,對(duì)應(yīng)服務(wù)的端口映射。

登錄 Web Harbor , 輸入用戶名 admin,默認(rèn)密碼(或已修改密碼)登錄系統(tǒng)。

我們可以看到系統(tǒng)各個(gè)模塊如下:

項(xiàng)目:新增/刪除項(xiàng)目,查看鏡像倉庫,給項(xiàng)目添加成員、查看操作日志、復(fù)制項(xiàng)目等

日志:倉庫各個(gè)鏡像create、push、pull等操作日志

系統(tǒng)管理

  1. 用戶管理:新增/刪除用戶、設(shè)置管理員等
  2. 復(fù)制管理:新增/刪除從庫目標(biāo)、新建/刪除/啟停復(fù)制規(guī)則等
  3. 配置管理:認(rèn)證模式、復(fù)制、郵箱設(shè)置、系統(tǒng)設(shè)置等

其他設(shè)置

  1. 用戶設(shè)置:修改用戶名、郵箱、名稱信息
  2. 修改密碼:修改用戶密碼

注意:非系統(tǒng)管理員用戶登錄,只能看到有權(quán)限的項(xiàng)目和日志,其他模塊不可見。

我們要嘗試下能不能把自己 Docker 里面的鏡像 push 到 Harbor 的 library 里來(默認(rèn)這個(gè) library 項(xiàng)目是公開的,所有人都可以有讀的權(quán)限,都不需要 docker login 進(jìn)來,就可以拉取里面的鏡像)。

注意:

為了后面留坑,我這里先 在自己的 docker.service 中添加倉庫:(這是個(gè)坑,建議你先按照我說的做,不然下面可能會(huì)一直登錄不上)

vim /usr/lib/systemd/system/docker.service
#里面的這行修改為:(其實(shí)就是添加 --insecure-registry 115.159.227.249 )
ExecStart=/usr/bin/dockerd --insecure-registry 115.159.227.249

添加完了后重新啟動(dòng) docker:

systemctl daemon-reload && systemctl enable docker && systemctl start docker

啟動(dòng) docker 服務(wù):

service docker start

登錄:(為了測試下能否登錄成功)

admin登錄
$ docker login 115.159.227.249
Username: admin
Password:
Login Succeeded

打 tag 并 push

docker tag ubuntu:15.10 115.159.227.249/library/ubuntu:15.10    //給我的鏡像打個(gè) tag

docker push 115.159.227.249/library/ubuntu

The push refers to a repository [115.159.227.249/library/ubuntu]
98d59071f692: Pushed
af288f00b8a7: Pushed
4b955941a4d0: Pushed
f121afdbbd5d: Pushed
15.10: digest: sha256:ec89c4a90f45f5e103860191890f48d8379e0504a2881ff706aef0768dc0321b size: 1150

上傳完畢后,登錄Web Harbor,選擇項(xiàng)目 library,就可以看到我剛 push 的鏡像了。

同理,你也可以測試下從 Harbor pull 鏡像到你的 Docker 中去,這里就不繼續(xù)演示了。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除

    Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除

    這篇文章主要介紹了Docker如何根據(jù)名稱查詢?nèi)萜鱅D鏡像ID并停止刪除問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • 詳解Windows?利用?WSL2?安裝?Docker?的2種方式

    詳解Windows?利用?WSL2?安裝?Docker?的2種方式

    這篇文章主要介紹了Windows?利用?WSL2?安裝?Docker?的2種方式,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-10-10
  • docker build鏡像時(shí),無法訪問網(wǎng)絡(luò)問題

    docker build鏡像時(shí),無法訪問網(wǎng)絡(luò)問題

    這篇文章主要介紹了docker build鏡像時(shí),無法訪問網(wǎng)絡(luò)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Docker 拉取鏡像超時(shí)(親測 3 個(gè)有效鏡像源 + 避坑指南)

    Docker 拉取鏡像超時(shí)(親測 3 個(gè)有效鏡像源 + 避坑指南)

    Docker 默認(rèn)鏡像源在國外,國內(nèi)訪問經(jīng)常抽風(fēng),常規(guī)操作應(yīng)該是換國內(nèi)鏡像源,本文就來介紹一下三個(gè)國內(nèi)穩(wěn)定源,具有一定的參考價(jià)值,感興趣的可以了解一下
    2025-08-08
  • Docker?存儲(chǔ)管理的幾種方式

    Docker?存儲(chǔ)管理的幾種方式

    本文主要使用三種不同的方式將數(shù)據(jù)從Docker主機(jī)掛載到容器中,分別為卷(volumes),綁定掛載(bind?mounts),臨時(shí)文件系tmpfs,還介紹了數(shù)據(jù)卷容器、數(shù)據(jù)卷的備份與恢復(fù),對(duì)Docker?存儲(chǔ)管理相關(guān)知識(shí)感興趣的朋友一起看看吧
    2022-07-07
  • Docker容器日志占用空間過大問題及解決

    Docker容器日志占用空間過大問題及解決

    這篇文章主要介紹了Docker容器日志占用空間過大問題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • Docker容器遷移Oracle到MySQL的實(shí)現(xiàn)方法

    Docker容器遷移Oracle到MySQL的實(shí)現(xiàn)方法

    本文主要介紹了Docker容器遷移Oracle到MySQL的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • Docker運(yùn)行模式之-d和-it的區(qū)別與選擇詳細(xì)對(duì)比

    Docker運(yùn)行模式之-d和-it的區(qū)別與選擇詳細(xì)對(duì)比

    這篇文章主要介紹了Docker運(yùn)行模式之-d和-it的區(qū)別與選擇詳細(xì)對(duì)比的相關(guān)資料,Docker中-d用于后臺(tái)運(yùn)行服務(wù),不阻塞終端;-it提供交互終端,支持用戶操作,需要的朋友可以參考下
    2025-05-05
  • Docker如何查看鏡像里的文件

    Docker如何查看鏡像里的文件

    文章介紹了如何在開發(fā)過程中檢查Docker鏡像中的文件是否符合預(yù)期,步驟包括下載鏡像、創(chuàng)建并運(yùn)行臨時(shí)容器查看內(nèi)容,以及停止和刪除臨時(shí)容器
    2024-11-11
  • Docker部署postgresql的方法實(shí)現(xiàn)

    Docker部署postgresql的方法實(shí)現(xiàn)

    本文主要介紹了Docker部署postgresql的方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2025-01-01

最新評(píng)論

芷江| 大英县| 雷波县| 青川县| 蓬安县| 普定县| 宜川县| 肇庆市| 个旧市| 汕尾市| 昭苏县| 安阳市| 灵丘县| 平顶山市| 通化市| 临邑县| 应城市| 炉霍县| 收藏| 兰州市| 稷山县| 江北区| 诏安县| 白玉县| 松江区| 榆林市| 泸西县| 牡丹江市| 柞水县| 晋宁县| 南木林县| 昭觉县| 黄大仙区| 唐山市| 门头沟区| 巴马| 湖口县| 深水埗区| 平定县| 东乌珠穆沁旗| 桦川县|