docker 安裝Harbor

docker 安裝harbor

1.下載鏡像依賴

docker pull vmware/harbor-jobservice:v1.1.2
docker pull vmware/harbor-ui:v1.1.2
docker pull vmware/harbor-adminserver:v1.1.2
docker pull vmware/harbor-db:v1.1.2
docker pull vmware/registry:2.6.1-photon
docker pull vmware/harbor-notary-db:mariadb-10.1.10
docker pull vmware/nginx:1.11.5-patched
docker pull vmware/notary-photon:signer-0.5.0
docker pull vmware/notary-photon:server-0.5.0
docker pull vmware/harbor-log:v1.1.2
docker pull photon:1.0

2.Docker-compose 安裝

安裝方式一
#1赡突、下載指定版本的docker-compose
$ curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

#2、對二進制文件賦可執(zhí)行權限
$ sudo chmod +x /usr/local/bin/docker-compose

#3岂嗓、測試下docker-compose是否安裝成功
$ docker-compose --version
docker-compose version 1.13.0, build 1719ceb

安裝方式二:

推薦使用pip安裝docker-compose

#安裝pip
yum -y install epel-release
yum -y install python-pip

#確認版本
pip --version

#更新pip
pip install --upgrade pip

#安裝 docker-compose
pip install docker-compose
docker-compose version

3.下載Harbor安裝文件

1率寡、在線安裝包

$ wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-online-installer-v1.1.2.tgz
$ tar xvf harbor-online-installer-v1.1.2.tgz

2舆床、離線安裝包
wget https://github.com/vmware/harbor/releases/download/v1.1.2/harbor-offline-installer-v1.1.2.tgz tar xvf harbor-offline-installer-v1.1.2.tgz
我們這里選擇離線安裝包進行安裝哮肚,由于github 下載地址速度較慢稚茅,也可通過下面百度云下載

鏈接:https://pan.baidu.com/s/1qilnwv-IB2FIqFQwG0bLbA 密碼:py93

4.修改Harbor配置

habor 域名設置為 harbor.demo.com

cd harbor
vi harbor.cfg

## Configuration file of Harbor

#The IP address or hostname to access admin UI and registry service.
#DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname = harbor.demo.com

#The protocol for accessing the UI and token/notification service, by default it is http.
#It can be set to https if ssl is enabled on nginx.
ui_url_protocol = http

#The password for the root user of mysql db, change this before any production use.
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.mxhichina.com
email_server_port = 25
email_username = harbor@demo.com
email_password = 123456
email_from = harbor <harbor@demo.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.
#Change the admin password from UI after launching Harbor.
harbor_admin_password = Harbor12345

##By default the auth mode is db_auth, i.e. the credentials are stored in a local database.
#Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.
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 depending 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

#Turn on or off the self-registration feature
self_registration = on

#The expiration time (in minute) of token created by token service, default is 30 minutes
token_expiration = 30

#The flag to control what users have permission to create projects
#The default value "everyone" allows everyone to creates a project. 
#Set to "adminonly" so that only admin user can create project.
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************************
#############

默認是80端口,如果端口占用袱院,我們可以去修改docker-compose.yml文件中屎慢,對應服務映射本地的端口9999。

docker-compose.yml

proxy:
    image: vmware/nginx:1.11.5-patched
    container_name: nginx
    restart: always
    volumes:
      - ./common/config/nginx:/etc/nginx:z
    networks:
      - harbor
    ports:
      - 9999:80
      - 443:443
      - 4443:4443
    depends_on:
      - mysql
      - registry
      - ui
      - log
    logging:
      driver: "syslog"
      options:  

啟動 Harbor
修改完配置文件后忽洛,在的當前目錄執(zhí)行./install.sh

5.配置NGINX

cd /etc/nginx/
vi nginx.conf

server {
        listen          80;
        server_name     harbor.demo.com;
        root            /usr/share/nginx/html;

        include /etc/nginx/default.d/*.conf;

        location / {
            # 設置最大允許上傳單個的文件大小
            client_max_body_size 1024m;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://localhost:9999;
            index index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }


#檢查配置是否正確
nginx -t

#重啟服務
sudo systemctl restart nginx

6.訪問harbor 并提交鏡像

訪問剛設置的hostname即可 http://harbor.demo.com/

這是因為docker1.3.2版本開始默認docker registry使用的是https腻惠,我們設置Harbor默認http方式,所以當執(zhí)行用docker login欲虚、pull集灌、push等命令操作非https的docker regsitry的時就會報錯。

docker login harbor.demo.com
Username: admin
Password: 
Error response from daemon: Get https://harbor.demo.com/v2/: dial tcp 10.220.107.52:443: connect: connection refused

解決辦法:

#修改docker啟動配置
vi  /lib/systemd/system/docker.service
#修改前
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
#修改后
ExecStart=/usr/bin/dockerd --insecure-registry harbor.demo.com -H fd:// --containerd=/run/containerd/containerd.sock

7.harbor 重啟

cd /usr/local/harbor

1复哆、停止Harbor
$ docker-compose down -v
Stopping nginx ... done
Stopping harbor-jobservice ... done
......
Removing harbor-log ... done
Removing network harbor_harbor

2欣喧、啟動Harbor
$ docker-compose up -d
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... 
......
Creating nginx
Creating harbor-jobservice ... done

8.日志查看

日志存儲位置 /var/log/harbor/

本文由博客群發(fā)一文多發(fā)等運營工具平臺 OpenWrite 發(fā)布

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末腌零,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子唆阿,更是在濱河造成了極大的恐慌莱没,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,204評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件酷鸦,死亡現(xiàn)場離奇詭異饰躲,居然都是意外死亡,警方通過查閱死者的電腦和手機臼隔,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,091評論 3 395
  • 文/潘曉璐 我一進店門嘹裂,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人摔握,你說我怎么就攤上這事寄狼。” “怎么了氨淌?”我有些...
    開封第一講書人閱讀 164,548評論 0 354
  • 文/不壞的土叔 我叫張陵泊愧,是天一觀的道長。 經常有香客問我盛正,道長删咱,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,657評論 1 293
  • 正文 為了忘掉前任豪筝,我火速辦了婚禮痰滋,結果婚禮上,老公的妹妹穿的比我還像新娘续崖。我一直安慰自己敲街,他們只是感情好,可當我...
    茶點故事閱讀 67,689評論 6 392
  • 文/花漫 我一把揭開白布严望。 她就那樣靜靜地躺著多艇,像睡著了一般。 火紅的嫁衣襯著肌膚如雪像吻。 梳的紋絲不亂的頭發(fā)上峻黍,一...
    開封第一講書人閱讀 51,554評論 1 305
  • 那天,我揣著相機與錄音萧豆,去河邊找鬼奸披。 笑死,一個胖子當著我的面吹牛涮雷,可吹牛的內容都是我干的阵面。 我是一名探鬼主播,決...
    沈念sama閱讀 40,302評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼样刷!你這毒婦竟也來了仑扑?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,216評論 0 276
  • 序言:老撾萬榮一對情侶失蹤置鼻,失蹤者是張志新(化名)和其女友劉穎镇饮,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體箕母,經...
    沈念sama閱讀 45,661評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡储藐,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,851評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了嘶是。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片钙勃。...
    茶點故事閱讀 39,977評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖聂喇,靈堂內的尸體忽然破棺而出辖源,到底是詐尸還是另有隱情,我是刑警寧澤希太,帶...
    沈念sama閱讀 35,697評論 5 347
  • 正文 年R本政府宣布克饶,位于F島的核電站,受9級特大地震影響誊辉,放射性物質發(fā)生泄漏矾湃。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,306評論 3 330
  • 文/蒙蒙 一芥映、第九天 我趴在偏房一處隱蔽的房頂上張望洲尊。 院中可真熱鬧,春花似錦奈偏、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,898評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至棺滞,卻和暖如春裁蚁,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背继准。 一陣腳步聲響...
    開封第一講書人閱讀 33,019評論 1 270
  • 我被黑心中介騙來泰國打工枉证, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人移必。 一個月前我還...
    沈念sama閱讀 48,138評論 3 370
  • 正文 我出身青樓室谚,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子秒赤,可洞房花燭夜當晚...
    茶點故事閱讀 44,927評論 2 355