Harbor 私有倉庫搭建

一 :整體工作流程

工作機(jī)制.jpg

注意:這里為了清晰將docker 的客戶端和服務(wù)端(docker daemon)分開了否副,實(shí)際一般都在一臺(tái)機(jī)器上。當(dāng)然也有分開部署的。
docker 客戶端通過命令(api)向docker server 發(fā)送請求奋渔,docker server 與私有倉庫交互完成用戶的請求祖很,docker push / pull

二 :安裝部署

2.1 安裝docker

這里為了后面的k8s 集群安裝 ,安裝docker 18.06版本颇蜡。

1.安裝yum-utils (如有可省略)

yum install -y yum-utils

2.設(shè)置 docker yum 源

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  1. 版本預(yù)覽&安裝
yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce-18.06.1.ce-3.el7

4.啟動(dòng)&設(shè)置開機(jī)啟動(dòng)

systemctl start docker 
systemctl enable docker

5.查看docker 版本

docker version
[root@k8s-node1 docker]# docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:23:03 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:25:29 2018
  OS/Arch:          linux/amd64
  Experimental:     false

3.1 Harbor 安裝

1.Harbor 鏡像 依賴 docker-compose 管理
上GitHub下載最新的release版本https://github.com/vmware/harbor/releases
docker-compose 版本 :https://github.com/docker/compose/releases/
這里下載的是

v1.7.1

下載 Harbor online installer

-rw-r--r--. 1 root root    381 2月  27 17:15 1
-rw-------. 1 root root   1423 8月  28 2018 anaconda-ks.cfg
drwxr-xr-x. 3 root root    251 2月  28 11:56 harbor
-rw-r--r--. 1 root root 163595 2月  28 14:37 harbor-online-installer-v1.7.1.tgz
  1. 解壓得到harbor
tar -zxvf harbor-online-installer-v1.7.1.tgz

3.進(jìn)行最簡單配置

cd harbor
-rw-r--r--. 1 root root    238 2月  28 11:56 1
drwxr-xr-x. 4 root root     37 2月  27 17:23 common
-rw-r--r--. 1 root root    939 1月   7 13:53 docker-compose.chartmuseum.yml
-rw-r--r--. 1 root root    975 1月   7 13:53 docker-compose.clair.yml
-rw-r--r--. 1 root root   1434 1月   7 13:53 docker-compose.notary.yml
-rw-r--r--. 1 root root   5608 1月   7 13:53 docker-compose.yml
-rw-r--r--. 1 root root   8031 2月  28 11:49 harbor.cfg
-rwxr-xr-x. 1 root root   5739 1月   7 13:53 install.sh
-rw-r--r--. 1 root root  11347 1月   7 13:53 LICENSE
-rw-r--r--. 1 root root 748160 1月   7 13:53 open_source_license
-rwxr-xr-x. 1 root root  36337 1月   7 13:53 prepare
#配置 harbor.cfg 
vim harbor.cfg 
#設(shè)置hostname
#This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY!
_version = 1.7.0
#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.
#DO NOT comment out this line, modify the value of "hostname" directly, or the installation will fail.
hostname = xxx.com(或者設(shè)置ip 192.168.229.20)

4.安裝

./install.sh

等待docker-compose 下載相關(guān)的docker image价说,默認(rèn)安裝完成后會(huì)自動(dòng)運(yùn)行相關(guān)鏡像

docker ps #查看
ad6b75b133db        goharbor/nginx-photon:v1.7.1                        "nginx -g 'daemon of…"   21 hours ago        Up 3 hours (healthy)   0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp   nginx
7b3d6fa358f1        goharbor/harbor-portal:v1.7.1                       "nginx -g 'daemon of…"   21 hours ago        Up 3 hours (healthy)   80/tcp                                                             harbor-portal
d248fb290d22        goharbor/harbor-jobservice:v1.7.1                   "/harbor/start.sh"       21 hours ago        Up 3 hours                                                                                harbor-jobservice
15947394ae84        goharbor/harbor-core:v1.7.1                         "/harbor/start.sh"       21 hours ago        Up 3 hours (healthy)                                                                      harbor-core
b40c1817fd99        goharbor/redis-photon:v1.7.1                        "docker-entrypoint.s…"   21 hours ago        Up 3 hours             6379/tcp                                                           redis
00c65a2b4239        goharbor/harbor-db:v1.7.1                           "/entrypoint.sh post…"   21 hours ago        Up 3 hours (healthy)   5432/tcp                                                           harbor-db
bab4d5e22e86        goharbor/harbor-registryctl:v1.7.1                  "/harbor/start.sh"       21 hours ago        Up 3 hours (healthy)                                                                      registryctl
6f83af4bfbc6        goharbor/registry-photon:v2.6.2-v1.7.1              "/entrypoint.sh /etc…"   21 hours ago        Up 3 hours (healthy)   5000/tcp                                                           registry
4326255fb989        goharbor/harbor-adminserver:v1.7.1                  "/harbor/start.sh"       21 hours ago        Up 3 hours (healthy)                                                                      harbor-adminserver
cd6ef6445d5d        goharbor/harbor-log:v1.7.1                          "/bin/sh -c /usr/loc…"   21 hours ago        Up 3 hours (healthy)   127.0.0.1:1514->10514/tcp                                          harbor-log

這里使用了nginx,默認(rèn)80端口提供服務(wù)风秤。
5.如需重啟/或者停止 Harbor

#切換到 harbor 目錄
cd harbor
docker-compose stop
docker-compose start
docker-compose restart

查看 docker-compose 命令使用

docker-compose --help
[root@k8s-master harbor]# docker-compose --help
Define and run multi-container applications with Docker.

Usage:
  docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
  docker-compose -h|--help

Options:
  -f, --file FILE             Specify an alternate compose file
                              (default: docker-compose.yml)
  -p, --project-name NAME     Specify an alternate project name
                              (default: directory name)
  --verbose                   Show more output
  --log-level LEVEL           Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  --no-ansi                   Do not print ANSI control characters
  -v, --version               Print version and exit
  -H, --host HOST             Daemon socket to connect to

  --tls                       Use TLS; implied by --tlsverify
  --tlscacert CA_PATH         Trust certs signed only by this CA
  --tlscert CLIENT_CERT_PATH  Path to TLS certificate file
  --tlskey TLS_KEY_PATH       Path to TLS key file
  --tlsverify                 Use TLS and verify the remote
  --skip-hostname-check       Don't check the daemon's hostname against the
                              name specified in the client certificate
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)
  --compatibility             If set, Compose will attempt to convert deploy
                              keys in v3 files to their non-Swarm equivalent

Commands:
  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  config             Validate and view the Compose file
  create             Create services
  down               Stop and remove containers, networks, images, and volumes
  events             Receive real time events from containers
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push service images
  restart            Restart services
  rm                 Remove stopped containers
  run                Run a one-off command
  scale              Set number of containers for a service
  start              Start services
  stop               Stop services
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information

6.UI 界面登陸 admin/Harbor12345 (harbor.cfg 可查看/修改admin 密碼)
http://harborserver[ip]-> 192.168.x.20

harbor 首頁

內(nèi)容頁

4.1 push 鏡像到harbor 私有倉庫

1 .設(shè)置docker 私有倉庫

#如果沒有 daemon.json 就是創(chuàng)建
vim /etc/docker/daemon.json
{
  "insecure-registries": ["192.168.229.20"]
}

如果不設(shè)置該私服地址會(huì)出現(xiàn) xxxx 443 類似的錯(cuò)誤鳖目,也就是
Error response from daemon: Get https://192.168.x.20/v1/users/: dial tcp 192.168.229.20:443: getsockopt: connection refused
harbor 默認(rèn)使用 https ,這里的配置就是 告訴 docker daemon 支持 http 訪問方式缤弦,并在設(shè)置了代理服務(wù)器地址疑苔。簡單點(diǎn)就是配置私服地址,這個(gè)地址也可以作為鏡像倉庫(理解可能不準(zhǔn)確,請勿深究!)

  1. 登陸 到 harbor (類似登陸github)
docker login 192.168.229.20

命令行會(huì)提示 輸入 username/password惦费,可以是 admin/Harbor12345

[root@k8s-node1 docker]# docker login 192.168.229.20
Username: admin
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
[root@k8s-node1 docker]# 
  1. push 鏡像到 haebor 私服
[root@k8s-node1 docker]# docker images
REPOSITORY                                           TAG                 IMAGE ID            CREATED             SIZE
192.168.229.20/user/user-setvice                     v2.0                3dc0481535b8        2 hours ago         122MB
nginx                                                alpine              b411e34b4606        3 weeks ago         16.1MB
registry.aliyuncs.com/google_containers/kube-proxy   v1.13.1             fdb321fd30a0        2 months ago        80.2MB
quay.io/coreos/flannel                               v0.10.0-amd64       f0fad859c909        13 months ago       44.6MB
registry.aliyuncs.com/google_containers/pause        3.1                 da86e6ba6ca1        14 months ago       742kB
nginx                                                1.9.1               94ec7e53edfc        3 years ago         133MB
nginx                                                1.7.9               84581e99d807        4 years ago         91.7MB

注意: 192.168.229.20/user/user-setvice:v2.0 鏡像的tag 必須是 私服ip[域名]/項(xiàng)目名稱/自定義:tag
192.168.x.20 : 私服ip
user :harbor 創(chuàng)建的項(xiàng)目名稱 user
user-sertvice: 自定義 名稱

項(xiàng)目列表

#push
docker push 192.168.229.20/user/user-setvice:v2.0
#pull
docker pull 192.168.229.20/user/user-setvice:v2.0
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末兵迅,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子薪贫,更是在濱河造成了極大的恐慌恍箭,老刑警劉巖,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件瞧省,死亡現(xiàn)場離奇詭異扯夭,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)鞍匾,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進(jìn)店門交洗,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人橡淑,你說我怎么就攤上這事构拳。” “怎么了梁棠?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵置森,是天一觀的道長。 經(jīng)常有香客問我符糊,道長凫海,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任男娄,我火速辦了婚禮行贪,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘模闲。我一直安慰自己建瘫,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布围橡。 她就那樣靜靜地躺著暖混,像睡著了一般。 火紅的嫁衣襯著肌膚如雪翁授。 梳的紋絲不亂的頭發(fā)上拣播,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天,我揣著相機(jī)與錄音收擦,去河邊找鬼贮配。 笑死,一個(gè)胖子當(dāng)著我的面吹牛塞赂,可吹牛的內(nèi)容都是我干的泪勒。 我是一名探鬼主播,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼圆存!你這毒婦竟也來了叼旋?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤沦辙,失蹤者是張志新(化名)和其女友劉穎夫植,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體油讯,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡详民,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了陌兑。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片沈跨。...
    茶點(diǎn)故事閱讀 40,127評論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖兔综,靈堂內(nèi)的尸體忽然破棺而出饿凛,到底是詐尸還是另有隱情,我是刑警寧澤邻奠,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布笤喳,位于F島的核電站为居,受9級(jí)特大地震影響碌宴,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜蒙畴,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一贰镣、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧膳凝,春花似錦碑隆、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至著淆,卻和暖如春劫狠,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背永部。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工独泞, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人苔埋。 一個(gè)月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓懦砂,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子荞膘,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,066評論 2 355

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