您好,登錄后才能下訂單哦!
怎么實現Docker私有倉庫Registry 搭建,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
signdomain=a.b.cn
mkdir ~/certs
openssl req -nodes -subj "/C=CN/ST=ZheJiang/L=HangZhou/CN=$signdomain" -newkey rsa:4096 -keyout ~/certs/$signdomain.key -out ~/certs/$signdomain.csr
openssl x509 -req -days 3650 -in ~/certs/$signdomain.csr -signkey ~/certs/$signdomain.key -out ~/certs/$signdomain.crt
docker run -d -p 5000:5000 --restart=always --name registry \ -v ~/certs:/certs \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/$signdomain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/$signdomain.key \ registry:2
docker tag ubuntu a.b.cn:5000/ubuntu
docker push a.b.cn:5000/ubuntu
#==>出現如下錯誤:
The push refers to a repository [a.b.cn:5000/ubuntu] (len: 1)
unable to ping registry endpoint https://a.b.cn:5000/v0/
v2 ping attempt failed with error: Get https://a.b.cn:5000/v2/: x509: certificate signed by unknown authority
v1 ping attempt failed with error: Get https://a.b.cn:5000/v1/_ping: x509: certificate signed by unknown authority
mkdir /etc/docker/certs.d/$signdomain:5000
cp ~/certs/$signdomain.crt /etc/docker/certs.d/$signdomain:5000/ca.crt
docker pull a.b.cn:5000/ubuntu
整體:
#導入registry v2 鏡像包 sudo docker load < registry.2.tar #設置registry所在主機域名或主機名 signdomain=docker-1 #設置registry認證文件目錄 sudo mkdir ~/certs #openssl生成認證文件 sudo openssl req -nodes -subj "/C=CN/ST=ZheJiang/L=HangZhou/CN=$signdomain" -newkey rsa:4096 -keyout ~/certs/$signdomain.key -out ~/certs/$signdomain.csr sudo openssl x509 -req -days 3650 -in ~/certs/$signdomain.csr -signkey ~/certs/$signdomain.key -out ~/certs/$signdomain.crt #運行registry容器 sudo docker run -d -p 5000:5000 --name registry -v ~/certs:/certs -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/$signdomain.crt -e REGISTRY_HTTP_TLS_KEY=/certs/$signdomain.key registry:2 #將crt文件復制到各docker Damon所在主機的/etc/docker/cert.d/$signdomain:5000目錄(不存在先新建) sudo mkdir /etc/docker/certs.d/ sudo mkdir /etc/docker/certs.d/$signdomain:5000 sudo cp ~/certs/$signdomain.crt /etc/docker/certs.d/$signdomain:5000/ca.crt #測試registry服務 sudo docker tag registry:2 docker-1:5000/registry:2 sudo docker push docker-1:5000/registry:2
關于怎么實現Docker私有倉庫Registry 搭建問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。