本篇内容介绍了“linux中如何搭建Docker私有仓库”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!使用Docker私有仓库可以帮助我们节
本篇内容介绍了“linux中如何搭建Docker私有仓库”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
使用Docker私有仓库可以帮助我们节省网络带宽,针对于每个镜像不用每个人都去中央仓库上面去下载,只需要从私有仓库中下载即可,还可以提供镜像资源利用,针对于公司内部使用的镜像,推送到本地的私有仓库中,以供公司内部相关人员使用。
[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
[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 imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/Wordpress latest 346b1443b020 30 hours aGo 407 MB[root@test01 ~]# docker push 192.168.1.30:5000/wordpressThe 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 imagesREPOSITORY TAG IMAGE ID CREATED SIZE192.168.1.30:5000/wordpress latest 346b1443b020 30 hours ago 407 MBdocker.io/wordpress latest 346b1443b020 30 hours ago 407 MB[root@test01 ~]# docker push 192.168.1.30:5000/wordpressThe 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 runsOPTIONS='--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/dockerfi
“Linux中如何搭建Docker私有仓库”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!
--结束END--
本文标题: Linux中如何搭建Docker私有仓库
本文链接: https://www.lsjlt.com/news/313239.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0