资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

如何在Linux系统上部署docker私有仓库

这篇文章给大家分享的是有关如何在Linux系统上部署docker私有仓库的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

10余年的西吉网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整西吉建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“西吉网站设计”,“西吉网站推广”以来,每个客户项目都认真落实执行。

修改配置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私有仓库”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!


标题名称:如何在Linux系统上部署docker私有仓库
当前链接:http://cdkjz.cn/article/jcodjc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220