Harbor: 企業級映象倉庫
官方地址
https://github.com/goharbor/harbor
1. 安裝docker 17.03.0-ce+ and docker-compose 1.18.0+
2. 安裝Harbor
安裝文件
https://github.com/goharbor/harbor/blob/master/docs/installation_guide.md
下載
# 進入下載目錄
cd /usr/src/
# 下載離線安裝包
wget https://storage.googleapis.com/harbor-releases/release-1.8.0/harbor-offline-installer-v1.8.0.tgz
# 解壓安裝包
tar xvf harbor-offline-installer-v1.8.0.tgz
# 進入Harbor目錄
cd harbor
配置Harbor
vim harbor.yml
# 配置如下
hostname: harbor.phpdev.com
port: 9010
harbor_admin_password: phpdev-pass
# The location to store harbor's data
data_volume: /usr/src/harbor/data
# The directory to store store log
location: /var/log/harbor
安裝
./install.sh
配置hosts, 瀏覽器訪問 http://harbor.phpdev.com:9010
# 登入
admin phpdev-pass
啟動/停止
docker-compose start/stop
3. 使用
1. 建立 wyx 使用者
2. 建立 test 專案
3. 為 test 專案新增 wyx 使用者, 角色是專案管理員
登入報錯
[root@localhost harbor]# docker login harbor.phpdev.com:9010
Username: wyx
Password:
Error response from daemon: Get https://harbor.phpdev.com:9010/v2/: dial tcp 192.168.246.128:9010: connect: connection refused
這是由於預設docker registry使用的是https, 而目前的Harbor使用的是http, 解決方法如下
# 查詢 docker.service 所在目錄
[root@localhost harbor]# find / -name docker.service -type f
/usr/lib/systemd/system/docker.service
# 增加 --insecure-registry harbor.phpdev.com:9010
[root@localhost harbor]# vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --insecure-registry harbor.phpdev.com:9010 -H fd:// --containerd=/run/containerd/containerd.sock
# 重新載入配置、重啟docker
systemctl daemon-reload
systemctl restart docker
再次登入
[root@localhost harbor]# docker login harbor.phpdev.com:9010
Username: wyx
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
Harbor推送拉取映象
推送
# 拉取一個測試映象
docker pull daocloud.io/daocloud/phpmyadmin
[root@localhost harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
daocloud.io/daocloud/phpmyadmin latest 626319eaebed 5 days ago 421MB
# 標記本地映象, 將其歸入某一倉庫(harbor.phpdev.com)
docker tag daocloud.io/daocloud/phpmyadmin:latest harbor.phpdev.com:9010/test/phpmyadmin:v1
[root@localhost harbor]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
daocloud.io/daocloud/phpmyadmin latest 626319eaebed 5 days ago 421MB
harbor.phpdev.com:9010/test/phpmyadmin v1 626319eaebed 5 days ago 421MB
# 將本地映象推送到映象倉庫(需先登入映象倉庫)
docker push harbor.phpdev.com:9010/test/phpmyadmin:v1
拉取
# 刪除原來映象
docker rmi daocloud.io/daocloud/phpmyadmin
docker rmi harbor.phpdev.com:9010/test/phpmyadmin:v1
# 拉取
docker pull harbor.phpdev.com:9010/test/phpmyadmin:v1
本作品採用《CC 協議》,轉載必須註明作者和本文連結