我尝试使用docker 1.8在注册表2.1.1版本中发布的pull through缓存docker。在CentOS7.1上但是,我遵循这些网站,并没有充当镜像,任何输入将非常感激。我希望这是配置注册表服务和传递docker守护程序参数的正确方法。
的网站: 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"}}]}
答案 0 :(得分:1)
它对我有用...
docker run -p 5000:5000 \
-e STANDALONE=false \
-e MIRROR_SOURCE=https://registry-1.docker.io \
-e MIRROR_SOURCE_INDEX=https://index.docker.io \
-e "REGISTRY_LOG_LEVEL=debug" \
-e "REGISTRY_REDIRECT_DISABLE=true" \
-v /var/lib/registry:/var/lib/registry \
--name registry-cache-latest \
registry
..然后将pointintg --registry-mirror映射到http服务器,而不是https。