(六)Docker-compose harbor
阿新 • • 發佈:2018-12-10
下載harbor,由於檔案過大,下載會需要很長時間
[[email protected] ~]# wget -q https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-offline-installer-v1.6.2.tgz [[email protected] ~]# ll -h harbor-offline-installer-v1.6.2.tgz -rw-r--r--. 1 root root 629M Nov 21 03:44 harbor-offline-installer-v1.6.2.tgz
yum安裝docker-compose
[[email protected] ~]# yum install docker-compose -y
[[email protected] ~]# rpm -qa docker-compose
docker-compose-1.18.0-2.el7.noarch
和官網給的md5值對比下,確保檔案沒問題
[[email protected] ~]# md5sum harbor-offline-installer-v1.6.2.tgz a2f12428425bbc14faab6c1c1bbf7272 harbor-offline-installer-v1.6.2.tgz # 解壓檔案到/usr/local/ [
[email protected] ~]# tar xf harbor-offline-installer-v1.6.2.tgz -C /usr/local/ [[email protected] ~]# cd /usr/local/harbor/ [[email protected] harbor]# ll -h total 637M drwxr-xr-x. 3 root root 23 Nov 27 07:37 common -rw-r--r--. 1 root root 813 Nov 19 02:02 docker-compose.chartmuseum.yml -rw-r--r--. 1 root root 863 Nov 19 02:02 docker-compose.clair.yml -rw-r--r--. 1 root root 1.3K Nov 19 02:02 docker-compose.notary.yml -rw-r--r--. 1 root root 3.6K Nov 19 02:02 docker-compose.yml drwxr-xr-x. 3 root root 164 Nov 19 02:02 ha -rw-r--r--. 1 root root 7.8K Nov 19 02:02 harbor.cfg -rw-r--r--. 1 root root 635M Nov 19 02:02 harbor.v1.6.2.tar.gz -rwxr-xr-x. 1 root root 6.1K Nov 19 02:02 install.sh -rw-r--r--. 1 root root 11K Nov 19 02:02 LICENSE -rw-r--r--. 1 root root 482 Nov 19 02:02 NOTICE -rw-r--r--. 1 root root 1.5M Nov 19 02:02 open_source_license -rwxr-xr-x. 1 root root 39K Nov 19 02:02 prepare
啟動前修改配置檔案,最主要兩個引數,一個admin密碼另一個db密碼
[[email protected] harbor]# vim harbor.cfg
hostname = node2.docker.com
harbor_admin_password = Harbor12345 # 初始密碼
db_password = root123 # 資料庫初始密碼
執行harbor,這個過程也會慢些,這裡最好在harbor目錄下執行,方便操作
[[email protected] harbor]# ./install.sh
......
Now you should be able to visit the admin portal at http://node2.docker.com.
For more details, please visit https://github.com/goharbor/harbor .
[[email protected] harbor]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 127.0.0.1:1514 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::443 :::*
LISTEN 0 128 :::4443 :::*
LISTEN 0 128 :::2375 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
訪問 http://node2.docker.com/
測試
建立一個使用者
建立一個倉庫test
登陸普通使用者建立一個專案
本地標記映象
docker tag SOURCE_IMAGE[:TAG] node2.docker.com/rsqhttpd/IMAGE[:TAG]
推送映象到私有專案
docker push node2.docker.com/rsqhttpd/IMAGE[:TAG]
推送映象到本地倉庫
# 預設就是80埠
[[email protected] ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://3po4uu60.mirror.aliyuncs.com","https://registry.docker-cn.com"],
"insecure-registries": ["node2.docker.com"]
}
[[email protected] ~]# systemctl restart docker
[[email protected] ~]# docker images
給image重新打標籤
[[email protected] ~]# docker tag rsqhttpd:v0.2-1 node2.docker.com/rsqhttpd/rsqhttpd:v0.2-1
[[email protected] ~]# docker tag rsqhttpd:v0.2-2 node2.docker.com/rsqhttpd/rsqhttpd:v0.2-2
[[email protected] ~]# docker tag rsqhttpd:v0.2-3 node2.docker.com/rsqhttpd/rsqhttpd:v0.2-3
登入倉庫
[[email protected] ~]# docker login node2.docker.com
Username: rsq
Password:
推送本地映象到倉庫中
[[email protected] ~]# docker push node2.docker.com/rsqhttpd/rsqhttpd
檢視倉庫映象
暫停倉庫
[[email protected] ~]# cd /usr/local/harbor/
[[email protected] harbor]# docker-compose pause # 暫停
Pausing harbor-log ... done
Pausing harbor-db ... done
Pausing harbor-adminserver ... done
Pausing registry ... done
Pausing redis ... done
Pausing harbor-ui ... done
Pausing nginx ... done
Pausing harbor-jobservice ... done
[[email protected] harbor]# docker-compose unpause # 取消暫停
Unpausing harbor-jobservice ... done
Unpausing nginx ... done
Unpausing harbor-ui ... done
Unpausing redis ... done
Unpausing registry ... done
Unpausing harbor-adminserver ... done
Unpausing harbor-db ... done
Unpausing harbor-log ... done