【发布时间】:2015-09-11 19:43:41
【问题描述】:
我尝试通过 docker 1.8 的注册表 2.1.1 版本中发布的缓存 docker 拉取。在 CentOS7.1 但是,我关注了这些网站,它并没有作为镜像,任何输入将不胜感激。我希望这是配置注册表服务和传递 docker daemon 参数的正确方法。
网站: https://github.com/docker/distribution/blob/master/docs/mirror.md http://docs.master.dockerproject.org/articles/registry_mirror/
步骤:
-
我添加了参数以传递给 docker 守护进程并重新启动它:
# /etc/sysconfig/docker # # Other arguments to pass to the docker daemon process # These will be parsed by the sysv initscript and appended # to the arguments list passed to docker -d OPTIONS="--registry-mirror=http://localhost:5000" -
添加注册表配置并挂载到容器:
version: 0.1 log: fields: service: registry storage: cache: blobdescriptor: inmemory filesystem: rootdirectory: /var/lib/registry http: addr: :5000 headers: X-Content-Type-Options: [nosniff] health: storagedriver: enabled: true interval: 10s threshold: 3 proxy: remoteurl: https://registry-1.docker.io -
启动的注册表容器
docker run -d -p 5000:5000 --restart=always --name registry-mirror -v /opt/docker-registry/local/images:/var/lib/registry -v /opt/docker-registry/local/config/config.yml:/etc/docker/registry/config.yml -e STANDALONE=false -e MIRROR_SOURCE=https://registry-1.docker.io -e MIRROR_SOURCE_INDEX=https://index.docker.io registry:2.1.1 -
使用如下命令测试通过缓存拉取:
在我的镜像运行的情况下,拉出一个我以前没有拉过的图像(使用时间来计时)
从配置为 MIRROR_SOURCE 的 docker hub 拉取
$ time docker pull busybox:latest从本地机器中删除图像
$ docker rmi busybox:latest最后,这应该从缓存中重新拉取图像,这在我的情况下不起作用,而是从 docker hub 拉取。
$ time docker pull busybox:latest我还尝试查看主机文件系统中已安装的图像卷文件夹,但找不到。
$ ls /opt/docker-registry/local/images/docker/registry/v2/repositories/尝试对新图像进行 rest api 调用,但返回错误消息:
$ curl http://localhost:5000/v2/busybox/tags/list {"errors":[{"code":"NAME_UNKNOWN","message":"repository name not known to registry","detail":{"name":"busybox"}}]}
【问题讨论】:
-
有人找到解决这个问题的方法吗? @doss。