您好,登錄后才能下訂單哦!
怎么實(shí)現(xiàn)Docker私有倉(cāng)庫(kù)Registry 搭建,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
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
#==>出現(xiàn)如下錯(cuò)誤:
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
整體:
#導(dǎo)入registry v2 鏡像包 sudo docker load < registry.2.tar #設(shè)置registry所在主機(jī)域名或主機(jī)名 signdomain=docker-1 #設(shè)置registry認(rèn)證文件目錄 sudo mkdir ~/certs #openssl生成認(rèn)證文件 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 #運(yùn)行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文件復(fù)制到各docker Damon所在主機(jī)的/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 #測(cè)試registry服務(wù) sudo docker tag registry:2 docker-1:5000/registry:2 sudo docker push docker-1:5000/registry:2
關(guān)于怎么實(shí)現(xiàn)Docker私有倉(cāng)庫(kù)Registry 搭建問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。