您好,登錄后才能下訂單哦!
準備工作:
1.升級系統
cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum update -y
[root@harbor ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
2.配置DNS域名并測試
vi /etc/hosts
10.100.13.77 hctest.cn
下載yum源:wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安裝docker-ce
yum -y install docker-ce
啟動docker
systemctl start docker
配置docker國內鏡像:
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
重啟
systemctl restart docker
安裝docker-compose
curl -L https://github.com/docker/compose/releases/download/1.23.1/docker-compose-`uname -s-
uname -m` -o /usr/local/bin/docker-compose
授權
chmod +x /usr/local/bin/docker-compose
軟連接:
ln -sv /usr/local/bin/docker-compose /usr/sbin/docker-compose
[root@test ~]# docker-compose --version
docker-compose version 1.23.1, build b02f1306
安裝harbor
wget https://storage.googleapis.com/harbor-releases/release-1.6.0/harbor-online-installer-v1.6.2.tgz
tar -zxf harbor-online-installer-v1.6.2.tgz
mkdir /data
mv harbor /data/harbor
創建CA證書:
mkdir /data/cert;
cd /data/cert
openssl req -nodes -subj "/CN=hchctest.cn" -newkey rsa:4096 -keyout hchctest.cn.key -out hchctest.cn.csr
openssl x509 -req -days 3650 -in hchctest.cn.csr -signkey hchctest.cn.key -out hchctest.cn.crt
openssl x509 -req -in hchctest.cn.csr -CA hchctest.cn.crt -CAkey hchctest.cn.key -CAcreateserial -out hchctest.cn.crt -days 10000
配置harbor:
vim /data/harbor/ harbor.cfg
修改如下內容:
hostname = hctest.cn
ui_url_protocol = https
ssl_cert = /data/cert/hchctest.cn.crt
ssl_cert_key = /data/cert/hchctest.cn.key
harbor_admin_password = Harbor12345 #修改登錄密碼
啟動harbor
./install.sh
修改docker.service
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --graph=/data/docker -H unix:// --insecure-registry hchctest.cn
注:--graph=/data/docker docker鏡像存儲路徑
測試:
[root@test harbor]# docker login hctest.cn
Username: admin
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-compose服務編排的,可以直接使用docker-compose命令啟動。
不修改配置文件重啟: docker-compose start|stop|restart
1.停止harbor docker-compose down -v
2.啟動harbor docker-compose up -d
客戶端使用
注:因為https協議,所以客戶端需要crt 從服務端把hchctest.cn.crt拷貝過來
mkdir /etc/docker/certs.d/hchctest.cn/
scp /data/cert/hchctest.cn.crt root@master:/etc/docker/certs.d/hchctest.cn/
客戶端測試:
錯誤排查:
docker login時提示x509: certificate signed by unknown authority
解決方法: 自簽名的證書不被系統信任,需要把/hchctest.cn.crt拷貝到/etc/docker/certs.d/hchctest.cn/, 無需重啟docker
具體操作如下
mdkir /etc/docker/certs.d/hchctest.cn/;
cp /data/cert/hchctest.cn.crt /etc/docker/certs.d/hchctest.cn/
再次登錄解決問題!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。