共計 2372 個字符,預計需要花費 6 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章給大家分享的是有關如何在 Linux 系統上部署 docker 私有倉庫的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。
修改配置 http 訪問
[root@test01 ~]# cat /etc/docker/daemon.json
{registry-mirrors : [ https://registry.docker-cn.com], insecure-registries :[192.168.1.30:5000]}
如果不這樣配置,結果如下。這個問題可能是由于客戶端采用 https,docker registry 未采用 https 服務所致。一種處理方式是把客戶對地址“192.168.1.30:5000”請求改為 http
[root@test01 ~]# docker push 192.168.1.30:5000/centosThe push refers to a repository [192.168.1.30:5000/centos]
Get https://192.168.1.30:5000/v1/_ping: http: server gave HTTP response to HTTPS client
使用容器運行 docker-registry
[root@test01 ~]# docker run -d -p 5000:5000 --privileged=true -v /opt/data/registry:/tmp/registry --name= docker-registry registry
參數說明:
-v /opt/data/registry:/tmp/registry : 默認情況下,會將倉庫存放于容器內的 /tmp/registry 目錄下,指定本地目錄掛載到容器
–privileged=true :CentOS7 中的安全模塊 selinux 把權限禁掉了,參數給容器加特權,不加上傳鏡像會報權限錯誤 (OSError: [Errno 13] Permission denied: ‘/tmp/registry/repositories/liibrary’) 或者(Received unexpected HTTP status: 500 Internal Server Error)錯誤
上傳鏡像
[root@test01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/wordpress latest 346b1443b020 30 hours ago 407 MB
[root@test01 ~]# docker push 192.168.1.30:5000/wordpress
The push refers to a repository [192.168.1.30:5000/wordpress]
An image does not exist locally with the tag: 192.168.1.30:5000/wordpress
[root@test01 ~]#
根據提示,我們知道需要修改一下 tag 才能上傳
[root@test01 ~]# docker tag docker.io/wordpress 192.168.1.30:5000/wordpress
[root@test01 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.1.30:5000/wordpress latest 346b1443b020 30 hours ago 407 MB
docker.io/wordpress latest 346b1443b020 30 hours ago 407 MB
[root@test01 ~]# docker push 192.168.1.30:5000/wordpress
The push refers to a repository [192.168.1.30:5000/wordpress]
3d7c1bb6ce9f: Pushed
從私有倉庫中下載
[root@test01 ~]# docker pull 192.168.1.30:5000/wordpress
客戶端永久配置使用私有倉庫
加入 ADD_REGISTRY= --add-registry 192.168.1.30:5000
[root@test01 ~]# cat /etc/sysconfig/docker
# /etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs
OPTIONS= --selinux-enabled --log-driver=journald --signature-verification=false -H unix:///var/run/docker.sock -H 0.0.0.0:2376
ADD_REGISTRY= --add-registry 192.168.1.30:5000
if [ -z ${DOCKER_CERT_PATH} ]; then
DOCKER_CERT_PATH=/etc/docker
fi
感謝各位的閱讀!關于“如何在 Linux 系統上部署 docker 私有倉庫”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
向 AI 問一下細節
丸趣 TV 網 – 提供最優質的資源集合!
正文完