Docker怎么搭建本地仓库(docker,开发技术)

时间:2024-04-29 10:18:48 作者 : 石家庄SEO 分类 : 开发技术
  • TAG :

Docker怎么搭建本地仓库

一,本地安装

#yuminstall-ypython-devellibevent-develpython-pipgccxz-devel#pipinstalldocker-registry

二,使用官方 registry 镜像

#dockerrun-d-p5000:5000registry#将使用官方的registry镜像来启动本地的私有仓库,但是并没有启动,只是为你创建好

默认情况下,会将仓库存放于容器的 /tmp/registry 目录下,如果容器被删除,则数据也会丢失,所以我们可以通过 -v 参数来将镜像文件存放在本地的指定路径:

#dockerrun-d-p5000:5000-v/opt/data/registry:/tmp/registryregistry#dockerstart$(dockerps-l|grepregistry|awk'{print$1}')#启动仓库

要在本地仓库上传镜像,首先需要标记一个镜像,以下标记 busybox ,由于 busybox 镜像比较小,没有的建议先下载:

#dockerpullbuxybox#dockertagbusybox192.168.0.232:5000/busybox#对buxybox镜像进行标记#dockerimages#查看标记的镜像#dockerpush192.168.0.232:5000/busybox#然后开始上传吧2016/06/1411:01:17Error:Invalidregistryendpointhttps://192.168.0.232:5000/v1/:Gethttps://192.168.0.232:5000/v1/_ping:dialtcp192.168.0.232:5000:connectionrefused.IfthisprivateregistrysupportsonlyHTTPorHTTPSwithanunknownCAcertificate,pleaseadd`--insecure-registry192.168.0.232:5000`tothedaemon'sarguments.InthecaseofHTTPS,ifyouhaveaccesstotheregistry'sCAcertificate,noneedfortheflag;simplyplacetheCAcertificateat/etc/docker/certs.d/192.168.0.232:5000/ca.crt

呵呵,报错了!因为Docker从1.3.X之后默认docker registry使用的是https,所以当用docker pull命令下载远程镜像时,如果远程docker registry是非https的时候就会报上面的错误。

为了解决这个问题需要在启动docker server时增加启动参数:

#vim/etc/sysconfig/docker#ip换为自己的ipother_args="--insecure-registry192.168.0.232:5000"#默认为空的#servicedockerrestart#重启docker#dockerstart$(dockerps-l|grepregistry|awk'{print$1}')#启动registry#dockerpush192.168.0.232:5000/busybox#然后重新上传吧,这次肯定成功#curlhttp://192.168.0.232:5000/v1/search#查看上传的镜像{"num_results":1,"query":"","results":[{"description":"","name":"library/busybox"}]}

注意: /v1 代表 registry 的版本,使用 docker pull 安装的默认为 v1 版本。

测试:

使用另一台机器 pull 本地的私有仓库,但是要在 private registry 上使用 SSL,另一种就是强制使用普通方式,仍然像上面一样,在配置文件中加上以下参数:

other_args="--insecure-registry192.168.0.232:5000"

重启 docker 服务,然后 pull:

[root@stadocker]#dockerpull192.168.0.232:5000/busyboxPullingrepository192.168.0.232:5000/busybox437595becdeb:Downloadcomplete437595becdeb:Pullingimage(latest)from192.168.0.232:5000/busyboxStatus:Imageisuptodatefor192.168.0.232:5000/busybox:latest
Docker怎么搭建本地仓库
 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:Docker怎么搭建本地仓库的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:Linux下怎么配置Nginx和PHP下一篇:

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

(必须)

(必须,保密)

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