Linux中如何搭建Docker私有仓库(docker,linux,开发技术)

时间:2024-05-05 19:09:17 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

使用Docker私有仓库可以帮助我们节省网络带宽,针对于每个镜像不用每个人都去中央仓库上面去下载,只需要从私有仓库中下载即可,还可以提供镜像资源利用,针对于公司内部使用的镜像,推送到本地的私有仓库中,以供公司内部相关人员使用。

Linux中如何搭建Docker私有仓库

修改配置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~]#dockerpush192.168.1.30:5000/centosThepushreferstoarepository[192.168.1.30:5000/centos]Gethttps://192.168.1.30:5000/v1/_ping:http:servergaveHTTPresponsetoHTTPSclient

使用容器运行docker-registry

[root@test01~]#dockerrun-d-p5000: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:[Errno13]Permissiondenied:‘/tmp/registry/repositories/liibrary’)或者(ReceivedunexpectedHTTPstatus:500InternalServerError)错误

上传镜像

[root@test01~]#dockerimagesREPOSITORYTAGIMAGEIDCREATEDSIZEdocker.io/wordpresslatest346b1443b02030hoursago407MB[root@test01~]#dockerpush192.168.1.30:5000/wordpressThepushreferstoarepository[192.168.1.30:5000/wordpress]Animagedoesnotexistlocallywiththetag:192.168.1.30:5000/wordpress[root@test01~]#

根据提示,我们知道需要修改一下tag才能上传

[root@test01~]#dockertagdocker.io/wordpress192.168.1.30:5000/wordpress[root@test01~]#dockerimagesREPOSITORYTAGIMAGEIDCREATEDSIZE192.168.1.30:5000/wordpresslatest346b1443b02030hoursago407MBdocker.io/wordpresslatest346b1443b02030hoursago407MB[root@test01~]#dockerpush192.168.1.30:5000/wordpressThepushreferstoarepository[192.168.1.30:5000/wordpress]3d7c1bb6ce9f:Pushed

从私有仓库中下载

[root@test01~]#dockerpull192.168.1.30:5000/wordpress

客户端永久配置使用私有仓库

加入ADD_REGISTRY='--add-registry192.168.1.30:5000'[root@test01~]#cat/etc/sysconfig/docker#/etc/sysconfig/docker#ModifytheseoptionsifyouwanttochangethewaythedockerdaemonrunsOPTIONS='--selinux-enabled--log-driver=journald--signature-verification=false-Hunix:///var/run/docker.sock-H0.0.0.0:2376'ADD_REGISTRY='--add-registry192.168.1.30:5000'if[-z"${DOCKER_CERT_PATH}"];thenDOCKER_CERT_PATH=/etc/dockerfi
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Linux中如何搭建Docker私有仓库的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:Linux的partprobe命令有什么用下一篇:

4 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18