Harbor是由VMWare公司開源的容器映象倉庫。事實上,Harbor是在Docker Registry上進行了相應的企業級擴充套件, 從而獲得了更加廣泛的應用,這些新的企業級特性包括:管理使用者介面,基於角色的訪問控制 ,AD/LDAP整合以及 審計日誌等,足以滿足基本企業需求。
Github:https://github.com/goharbor/harbor
線上安裝:從Docker Hub下載Harbor相關映象,因此安裝軟體包非常小
https://github.com/docker/compose/releases
mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
tar zxvf harbor-offline-installer-v2.0.0.tgz
harbor_admin_password: Harbor12345
1、配置http映象倉庫可信任(預設是https訪問的,上面配置的是http,這裡需要配置可信任)
{"insecure-registries":["reg.azhe.com"]}
docker tag mysql:5.7 reg.azhe.com/library/mysql:5.7
docker push reg.azhe.com/library/mysql:5.7
docker pull reg.azhe.com/library/mysql:5.7
ca-config.json ca-key.pem cfssl.sh reg.azhe.com-key.pem
ca.csr ca.pem reg.azhe.com.csr reg.azhe.com.pem
ca-csr.json certs.sh reg.azhe.com-csr.json
wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
mv cfssl_linux-amd64 /usr/bin/cfssl
mv cfssljson_linux-amd64 /usr/bin/cfssljson
mv cfssl-certinfo_linux-amd64 /usr/bin/cfssl-certinfo
cfssl gencert -initca ca-csr.json | cfssljson -bare ca -
cat > reg.azhe.com-csr.json <<EOF
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes reg.azhe.com-csr.json | cfssljson -bare reg.azhe.com
certificate: /root/ssl/reg.azhe.com.pem #指定你生成的數字證書
private_key: /root/ssl/reg.azhe.com-key.pem #指定key
4、修改Docker啟動檔案新增“--insecure-registry reg.azhe.com”並配置hosts檔案
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry reg.azhe.com
docker pull reg.azhe.com/library/mysql:5.7
以上harbor部署https方式的第4步驟,如果配置完成後,在docker主機登入harbor報證書錯誤,那麼可以透過以下方式解決或參考連結:
scp reg.azhe.com.pem root@192.168.0.13:~ #複製到要登入harbor的docker客戶端
mkdir /etc/docker/certs.d/reg.azhe.com
cp reg.azhe.com.pem /etc/docker/certs.d/reg.azhe.com/reg.azhe.com.crt
https://blog.csdn.net/chenglang0914/article/details/100833054
mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
tar -zxf harbor-offline-installer-v2.0.0.tgz
harbor_admin_password: Harbor12345
3.客戶端docker主機上傳映象到主harbor並驗證是否複製到從harbor
docker tag centos:7 reg.azhe.com/library/centos:7
docker push reg.azhe.com/library/centos:7