docker harbor鏡像倉庫

docker harbor安裝使用:nginx

https://github.com/goharbor/harbor/releasesgit

 

有離線安裝和在線安裝兩種方式github

安裝:docker

一、下載安裝包數據庫

https://github.com/goharbor/harbor/releasesjson

在線安裝包,體積小:vim

wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-online-installer-v1.8.1.tgzcentos

離線安裝包,體積大:api

wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.1.tgz安全

二、修改配置文件

tar -xvf harbor-online-installer-v1.8.1.tgz

cd harbor/

vim harbor.yml

hostname: 118.xxx.xxx.xxx    #主機名,能夠是域名和IP

port: 80    #訪問端口,作了ssl域名正式能夠設置成443

harbor_admin_password: Harbor12345   #harbor頁面等登陸密碼

database:

  password: root123    #數據庫密碼

data_volume: /data  #數據卷的路徑,是本機的真實路徑

 

三、下載docker-compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

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

四、執行安裝腳本

./install.sh

五、登陸harbor界面

http://ip

用戶名:admin

密碼:Harbor12345

 

六、啓動和中止harbor

cd harbor#啓動和中止harbor須要找docker-compose.yml文件,因此必須進入harbor安裝目或者-f指定harbor項目的docker-compose.yml

docker-compose start/stop

七、推送鏡像

docker tag SOURCE_IMAGE[:TAG] 118.xxx.xxx.xxx/myproject/IMAGE[:TAG] #打標籤

docker push 118.xxx.xxx.xxx/myproject/IMAGE[:TAG] #推送

推送執行時報錯:

1) The push refers to repository 118.xxx.xxx.xxx/myproject/nginx]

Get https://118.xxx.xxx.xxx/v2/: dial tcp 118.xxx.xxx.xxx:443: connect: connection refused

這是由於默認狀況下訪問的是443端口,須要證書認證,咱們沒有,須要在配置文件中添加倉庫安全地址

[root@VM_0_3_centos harbor]# cat /etc/docker/daemon.json

{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],

"insecure-registries": ["118.xxx.xxx.xxx"]

}

2) The push refers to repository [118.xxx.xxx.xxx/myproject/nginx]

d7acf794921f: Preparing

d9569ca04881: Preparing

cf5b3c6798f7: Preparing

denied: requested access to the resource is denied

由於咱們建立的項目是私有項目,須要登陸以後才能上傳鏡像

[root@VM_0_3_centos ~]# docker login 118.xxx.xxx.xxx

Username: admin

Password:#若是沒有改動過,admin密碼是Harbor12345,也能夠在harbor上爲項目建立一個用戶

3) docker login發生錯誤

Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

須要給docker添加dns配置

[root@VM_0_3_centos harbor]# cat /etc/docker/daemon.json

{"registry-mirrors": ["http://f1361db2.m.daocloud.io"],

"insecure-registries": ["118.xxx.xxx.xxx"],

"dns":["8.8.8.8","114.114.114.114"]

}

相關文章
相關標籤/搜索