主頁 > 知識庫 > Docker 搭建私有倉庫(registry、harbor)

Docker 搭建私有倉庫(registry、harbor)

熱門標(biāo)簽:地圖標(biāo)注員怎么去做 德州外呼系統(tǒng)排名 貴州全自動外呼系統(tǒng)廠家 上海電銷卡外呼系統(tǒng)廠家 福州外呼系統(tǒng)中間件 機(jī)器人電銷有什么用 百度地圖標(biāo)注備注 好看的地圖標(biāo)注圖標(biāo)下載 威海人工智能電銷機(jī)器人系統(tǒng)

為什么要弄私有倉庫,大多是為了速度,我們再私有倉庫中的push和pull的速度是特別快的。

利用registry快速搭建

https://hub.docker.com/_/registry/

Run a local registry: Quick Version
$ docker run -d -p 5000:5000 --restart always --name registry registry:2
Now, use it from within Docker:

$ docker pull ubuntu
$ docker tag ubuntu localhost:5000/ubuntu
$ docker push localhost:5000/ubuntu

這是官方的一個小demo。下面是我自己的實(shí)踐。

# 拉取registry2.0版本
[root@FantJ ~]# docker pull registry:2
Trying to pull repository docker.io/library/registry ... 
2: Pulling from docker.io/library/registry
81033e7c1d6a: Pull complete 
b235084c2315: Pull complete 
c692f3a6894b: Pull complete 
ba2177f3a70e: Pull complete 
a8d793620947: Pull complete 
Digest: sha256:672d519d7fd7bbc7a448d17956ebeefe225d5eb27509d8dc5ce67ecb4a0bce54
Status: Downloaded newer image for docker.io/registry:2
# 后臺啟動運(yùn)行
[root@FantJ ~]# docker run -d -p 5000:5000 --restart always --name registry registry:2
ce5b8bfa6d7f535906730ea3a058b00e7cfdaaa20ea0db3c49d700a4e2c8a645
[root@FantJ ~]# docker images
REPOSITORY       TAG         IMAGE ID      CREATED       SIZE
docker.io/openjdk    8-jre        bef23b4b9cac    2 weeks ago     443 MB
docker.io/fantj/nginx  latest       ae513a47849c    4 weeks ago     109 MB
docker.io/nginx     latest       ae513a47849c    4 weeks ago     109 MB
docker.io/registry   2          d1fd7d86a825    4 months ago    33.3 MB
# tag 鏡像
[root@FantJ ~]# docker tag docker.io/nginx 127.0.0.1:5000/nginx
# 上傳到私有倉庫
[root@FantJ ~]# docker push 127.0.0.1:5000/nginx
The push refers to a repository [127.0.0.1:5000/nginx]
7ab428981537: Pushed 
82b81d779f83: Pushed 
d626a8ad97a1: Pushed 
latest: digest: sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90 size: 948
[root@FantJ ~]# 

缺點(diǎn):沒有可視化管理工具,私有倉庫服務(wù)宕機(jī)造成麻煩,沒有用戶管理機(jī)制、沒有操作的記錄功能。

優(yōu)點(diǎn):搭建操作簡單

利用harbor搭建

下載地址:https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.1.tgz

wget https://storage.googleapis.com/harbor-releases/release-1.5.0/harbor-offline-installer-v1.5.1.tgz

tar zxvf harbor-offline-installer-v1.5.1.tgz

cd harbor

修改配置harbor.cfg

hostname = fantj.top:8888 

http還是https啥的自己看著改

保存退出,直接運(yùn)行install.sh

cd ..
./install.sh

注意一點(diǎn):harbor默認(rèn)會占用80端口,所以請確保你的80端口不被占用,那怎么修改呢?

修改配置docker-compose.yml(需要改端口再進(jìn)行)

將80:80的第一個80改為自定義的端口號

我在這里改成8888端口。

然后運(yùn)行install.sh

......
[Step 4]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log
Creating redis
Creating registry
Creating harbor-db
Creating harbor-adminserver
Creating harbor-ui
Creating nginx
Creating harbor-jobservice

✔ ----Harbor has been installed and started successfully.----

Now you should be able to visit the admin portal at http://fantj.top:8888 . 
For more details, please visit https://github.com/vmware/harbor .

好的,成功了,我們來訪問一下。

默認(rèn)賬號密碼:
admin
Harbor12345

如果想修改,去harbor.cfg修改。

[root@FantJ harbor]# docker ps
CONTAINER ID    IMAGE                 COMMAND         CREATED       STATUS          PORTS                                NAMES
ea66b87c5d26    vmware/harbor-jobservice:v1.5.1    "/harbor/start.sh"    7 minutes ago    Up 7 minutes                                         harbor-jobservice
5fecbc47ea68    vmware/nginx-photon:v1.5.1       "nginx -g 'daemon ..."  7 minutes ago    Up 7 minutes (healthy)  0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:8888->80/tcp  nginx
9ccfa0d137de    vmware/harbor-ui:v1.5.1        "/harbor/start.sh"    7 minutes ago    Up 7 minutes (healthy)                                    harbor-ui
b1f6387545d6    vmware/harbor-db:v1.5.1        "/usr/local/bin/do..."  7 minutes ago    Up 7 minutes (healthy)  3306/tcp                               harbor-db
6bcd46635374    vmware/registry-photon:v2.6.2-v1.5.1  "/entrypoint.sh se..."  7 minutes ago    Up 7 minutes (healthy)  5000/tcp                               registry
c40db866f7d2    vmware/harbor-adminserver:v1.5.1    "/harbor/start.sh"    7 minutes ago    Up 7 minutes (healthy)                                    harbor-adminserver
8d0ee20abfbf    vmware/redis-photon:v1.5.1       "docker-entrypoint..."  7 minutes ago    Up 7 minutes       6379/tcp                               redis
17c002dd8b98    vmware/harbor-log:v1.5.1        "/bin/sh -c /usr/l..."  7 minutes ago    Up 7 minutes (healthy)  127.0.0.1:1514->10514/tcp                      harbor-log
[root@FantJ harbor]# docker images
REPOSITORY          TAG         IMAGE ID      CREATED       SIZE
vmware/redis-photon      v1.5.1       19245c7a4f51    3 days ago     207 MB
vmware/clair-photon      v2.0.1-v1.5.1    e7f0ab982469    3 days ago     303 MB
vmware/notary-server-photon  v0.5.1-v1.5.1    611385e920c3    3 days ago     211 MB
vmware/notary-signer-photon  v0.5.1-v1.5.1    f9e01495db0e    3 days ago     209 MB
vmware/registry-photon    v2.6.2-v1.5.1    2efae6b250b1    3 days ago     198 MB
vmware/nginx-photon      v1.5.1       90d35cd72a68    3 days ago     135 MB
vmware/harbor-log       v1.5.1       67000769dfac    3 days ago     200 MB
vmware/harbor-jobservice   v1.5.1       3f7a7987ca5b    3 days ago     194 MB
vmware/harbor-ui       v1.5.1       8dbe945233a8    3 days ago     212 MB
vmware/harbor-adminserver   v1.5.1       a11b8eb3f9d8    3 days ago     183 MB
vmware/harbor-db       v1.5.1       afa780d73279    3 days ago     526 MB
vmware/mariadb-photon     v1.5.1       59ed57632415    3 days ago     526 MB
vmware/postgresql-photon   v1.5.1       41b693c0ce50    3 days ago     221 MB
docker.io/openjdk       8-jre        bef23b4b9cac    2 weeks ago     443 MB
vmware/harbor-migrator    v1.5.0       466c57ab0dc3    4 weeks ago     1.16 GB
127.0.0.1:5000/nginx     latest       ae513a47849c    4 weeks ago     109 MB
docker.io/fantj/nginx     latest       ae513a47849c    4 weeks ago     109 MB
docker.io/nginx        latest       ae513a47849c    4 weeks ago     109 MB
vmware/photon         1.0         4b481ecbef2a    5 weeks ago     130 MB
docker.io/registry      2          d1fd7d86a825    4 months ago    33.3 MB

可以看到我們的進(jìn)程和鏡像都多了很多的以vmware開頭的(harbor是vmware公司的開源工具).

好了,開始push測試

[root@FantJ harbor]# docker tag docker.io/nginx fantj.top:8888/internet-plus/nginx
[root@FantJ harbor]# docker push fantj.top:8888/internet-plus/nginx
The push refers to a repository [fantj.top:8888/internet-plus/nginx]
Get https://fantj.top:8888/v1/_ping: dial tcp: lookup fantj.top: no such host

它提示需要用https請求才安全,解決方式有兩種:

第一種:docker啟動的時(shí)候添加對域名+端口的信任 --insecure-registry=xxxx.xx.xx.xx:8888

第二種:添加ssl證書,改天更新

Harbor重啟

#docker-compose stop
# ./install.sh

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

標(biāo)簽:邵陽 南陽 泉州 南陽 白城 撫州 岳陽 葫蘆島

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Docker 搭建私有倉庫(registry、harbor)》,本文關(guān)鍵詞  Docker,搭建,私有,倉庫,registry,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Docker 搭建私有倉庫(registry、harbor)》相關(guān)的同類信息!
  • 本頁收集關(guān)于Docker 搭建私有倉庫(registry、harbor)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章